1
我試圖在HoloLens(C#)應用程序中打開一個打包在應用程序文件夾(「資產」)中的PDF文件。如何在HoloLens UWP的相關應用中啓動PDF文件?
string imageFile = @"Assets\test.jpg";
var file = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFileAsync(imageFile);
Debug.WriteLine("Opening file in path :" + file.Path);
if (file != null)
{
Debug.WriteLine("File found\nLaunching file...");
var options = new Windows.System.LauncherOptions();
options.DisplayApplicationPicker = true;
// Launch the retrieved file
var success = await Windows.System.Launcher.LaunchFileAsync(file);
if (success)
{
Debug.WriteLine("File launched successfully");
// File launched
}
else
{
Debug.WriteLine("File launch failed");
// File launch failed
}
}
else
{
Debug.WriteLine("Could not find file");
// Could not find file
}
獲得Access is Denied
錯誤。
Exception thrown: 'System.UnauthorizedAccessException' in mscorlib.ni.dll
System.UnauthorizedAccessException: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at SchneiderDemoLibrary.HoloHelper.<DefaultLaunch>d__3.MoveNext() Exception caught.
有人可以幫我解決這個問題嗎?我只是想打開一些與文件類型相關的應用程序的文件。
您是否嘗試過'的Process.Start(pdfFile)'? –
@JamesHughes通用Windows應用程序中沒有'Process.Start'。 – BrainSlugs83
得到它的工作。我試圖從Unity 3D運行此代碼。現在我已經動態創建了2D窗口,並在2D窗口加載時觸發了上述代碼。 –