对于Windows应用商店应用:如何在我的应用中打开 StorageFile
在应用程序外部重命名或删除?
我在桌面上运行了一个Windows 10 UWP应用程序 . 该应用程序允许用户打开和编辑文档 .
我尝试过的事情:
-
Checking DateModified :
-
我试过检查
storageFile.GetBasicPropertiesAsync().DateModified
,但即使我删除了文件并清空了垃圾箱,调用也会成功返回(旧)DateModified
. (我假设它使用内存版本而不检查磁盘上的文件) -
Re-Open the StorageFile :
-
然后我尝试使用
StorageFile.GetFileFromPathAsync(file.Path)
"re-open"文件 . 这是第一次正确地扔了FileNotFoundException
. -
但是,稍后会因
Unauthorized access/permission denied
异常而失败 . 这有点意义,因为我需要用户在FileOpenPicker中选择文件以使我的应用程序获得使用它的权限 . -
Monitor the parent folder:
-
与这个没有相差甚远 . 我试图使用
StorageFolder.CreateFileQuery()
,但我无法从StorageFile实例访问父文件夹(再次,它是有道理的,因为我的应用程序没有访问父文件夹的权限)
1 回答
即使在UWP应用程序中,您也可以使用
System.IO.File.Exists(String)
. https://msdn.microsoft.com/de-de/library/system.io.file.exists(v=vs.110).aspx