如何解决使用UWP GetFolderFromPathAsync时拒绝访问的问题 [英] how to solve access denied when using UWP GetFolderFromPathAsync

查看:148
本文介绍了如何解决使用UWP GetFolderFromPathAsync时拒绝访问的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试使用GetFolderFromPathAsync从我的UWP应用访问文件系统时,访问被拒绝.

I'm getting access denied when trying to access file system from my UWP app by using GetFolderFromPathAsync.

我的UWP应用需要访问Windows 10文件系统. 我正在使用broadFileSystemAccess,但是卡住了. 当我执行GetFolderFromPathAsync时,下面的代码将拒绝访问".

My UWP app needs to access the Windows 10 file system. I'm using broadFileSystemAccess but am stuck. My code below gets "access denied" when it does GetFolderFromPathAsync.

当我尝试设置清单文件类型时,出现以下错误.

And when I try to set the manifest file type, I get the errors below.

任何帮助都将不胜感激.

Any help greatly appreciated.

我的代码

                    StorageFolder test_StorageFolder = await StorageFolder.GetFolderFromPathAsync(@"C:\demo");
                    StorageFile sampleFile =    await test_StorageFolder.CreateFileAsync("test.txt",
                            Windows.Storage.CreationCollisionOption.ReplaceExisting);

我的清单错误...

MY MANIFEST ERROR...

验证错误.错误C00CE020:应用清单验证错误: 应用清单必须按照架构有效:第43行,第12列,原因: 缺少必需的属性名称".

Validation error. error C00CE020: App manifest validation error: The app manifest must be valid as per schema: Line 43, Column 12, Reason: Required attribute 'Name' is missing.

我的清单...

IE ...

> <?xml version="1.0" encoding="utf-8"?> <Package
> xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
> xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
> xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest"
> xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
> IgnorableNamespaces="uap mp build"
> xmlns:build="http://schemas.microsoft.com/developer/appx/2015/build"> 
> <!--
>     THIS PACKAGE MANIFEST FILE IS GENERATED BY THE BUILD PROCESS.
> 
>     Changes to this file will be lost when it is regenerated. To correct errors in this file, edit the source .appxmanifest file.
> 
>     For more information on package manifest files, see http://go.microsoft.com/fwlink/?LinkID=241727   -->   <Identity
> Name="Microsoft.SDKSamples.CameraFrames.CS" Publisher="CN=Microsoft
> Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US"
> Version="1.0.0.0" ProcessorArchitecture="x64" />   <mp:PhoneIdentity
> PhoneProductId="2344b9de-5071-42a6-8873-7fdeb38d53dd"
> PhonePublisherId="00000000-0000-0000-0000-000000000000" />  
> <Properties>
>     <DisplayName>Camera Frames C# Sample</DisplayName>
>     <PublisherDisplayName>Microsoft Corporation</PublisherDisplayName>
>     <Logo>Assets\StoreLogo-sdk.png</Logo>   </Properties>   <Dependencies>
>     <TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.17134.0" MaxVersionTested="10.0.17134.0" />  
> </Dependencies>   <Resources>
>     <Resource Language="EN-US" />   </Resources>   <Applications>
>     <Application Id="App" Executable="CameraFrames.exe" EntryPoint="CameraFrames.App">
>       <uap:VisualElements DisplayName="MOVANO System Hub Camera  interface" Square150x150Logo="Assets\SquareTile-sdk.png"
> Square44x44Logo="Assets\SmallTile-sdk.png" Description="Camera Frames
> C# Sample" BackgroundColor="#00b2f0">
>         <uap:SplashScreen Image="Assets\Splash-sdk.png" />
>         <uap:DefaultTile>
>           <uap:ShowNameOnTiles>
>             <uap:ShowOn Tile="square150x150Logo" />
>           </uap:ShowNameOnTiles>
>         </uap:DefaultTile>
>       </uap:VisualElements>
>       <Extensions>
>         <uap:Extension Category="windows.fileTypeAssociation">
>           <uap:FileTypeAssociation Name="access">
>             <uap:SupportedFileTypes>
>               <uap:FileType>.txt</uap:FileType>
>               <uap:FileType>.bin</uap:FileType>
>             </uap:SupportedFileTypes>
>           </uap:FileTypeAssociation>
>         </uap:Extension>
>         <uap:Extension Category="windows.fileTypeAssociation">
>           <uap:FileTypeAssociation>
>             <uap:SupportedFileTypes>
>               <uap:FileType></uap:FileType>
>             </uap:SupportedFileTypes>
>           </uap:FileTypeAssociation>
>         </uap:Extension>
>       </Extensions>
>     </Application>   </Applications>   <Capabilities>
>     <Capability Name="privateNetworkClientServer" />
>     <Capability Name="internetClientServer" />
>     <DeviceCapability Name="microphone" />
>     <DeviceCapability Name="webcam" />   </Capabilities>   <build:Metadata>
>     <build:Item Name="TargetFrameworkMoniker" Value=".NETCore,Version=v5.0" />
>     <build:Item Name="VisualStudio" Version="15.0" />
>     <build:Item Name="VisualStudioEdition" Value="Microsoft Visual Studio Professional 2017" />
>     <build:Item Name="OperatingSystem" Version="10.0.17134.1 (WinBuild.160101.0800)" />
>     <build:Item Name="Microsoft.Build.AppxPackage.dll" Version="15.0.28307.104" />
>     <build:Item Name="ProjectGUID" Value="{1BF84D6E-9DCE-5653-AC51-BB4FC694A252}" />
>     <build:Item Name="OptimizingToolset" Value="None" />
>     <build:Item Name="TargetRuntime" Value="Managed" />
>     <build:Item Name="Microsoft.Windows.UI.Xaml.Build.Tasks.dll" Version="15.0.28307.102" />
>     <build:Item Name="MakePri.exe" Version="10.0.17134.12 (WinBuild.160101.0800)" />   </build:Metadata> </Package>

推荐答案

我向Microsoft技术支持部门支付了500美元,并得到了秘密"答案.在这里,我的同伴编码员...

I paid Microsoft tech support $500 and got the 'secret' answer. Here it is, my fellow coders...

  1. 打开项目文件夹
  2. 删除.vs文件夹.
  3. 删除bin和obj
  4. 开放式解决方案
  5. 清洁溶液
  6. 右键单击解决方案->恢复NuGet程序包
  7. 打开项目清单代码(不是GUI)
  8. 更改
    IgnorableNamespaces="uap mp">
    IgnorableNamespaces="uap mp rescap">

  1. Open project folder
  2. delete .vs folder.
  3. delete bin and obj
  4. Open solution
  5. Clean solution
  6. Right-click solution -> Restore NuGet Packages
  7. Open project manifest code (not GUI)
  8. Change
    IgnorableNamespaces="uap mp"> to
    IgnorableNamespaces="uap mp rescap">

替换
<DeviceCapability xmlns:rescap=http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities<rescap:Capability Name="broadFileSystemAccess"/>

构建>配置管理器>活动解决方案平台= x64(默认为ARM)

Build > Config Manager > Active solution platform = x64 (it defaults to ARM)

您很高兴.

这篇关于如何解决使用UWP GetFolderFromPathAsync时拒绝访问的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆