我正在尝试在 HoloLens (C#) 应用程序中打开一个打包在应用程序文件夹(“资产”)中的 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.
有人可以帮我解决这个问题吗?我只是想用与文件类型关联的相应应用程序打开一些文件。