我希望我的代码重命名桌面上的文件,但我无权编辑桌面上的文件。我如何获得必要的许可?
我的代码:
public async Task RenameFile(fileLocation, newName)
{
try
{
StorageFile bkpFile = await StorageFile.GetFileFromPathAsync(fileLocation);
await bkpFile.RenameAsync(newName);
}
catch { /* Eat error */ }
}
我的Package.Appxmanifest文件中设置的权限:
<Capabilities>
<Capability Name="picturesLibrary" />
<Capability Name="documentsLibrary" />
<Capability Name="internetClient" />
<Capability Name="removableStorage" />
<Capability Name="enterpriseAuthentication" />
<Capability Name="videosLibrary" />
<Capability Name="privateNetworkClientServer" />
<DeviceCapability Name="location" />
<DeviceCapability Name="webcam" />
<DeviceCapability Name="microphone" />
<m2:DeviceCapability Name="bluetooth.rfcomm">
<m2:Device Id="any">
<m2:Function Type="name:serialPort" />
</m2:Device>
</m2:DeviceCapability>
</Capabilities>
编辑:我还需要权限重命名附加设备中的文件,例如SD卡和拇指驱动器。