简体   繁体   English

如果使用broadFileSystemAccess和runFullTrust,UWP应用程序可以更改另一个应用程序的AppData文件夹中的文件吗?

[英]Can a UWP app change files in another app's AppData folder if using broadFileSystemAccess and runFullTrust?

I have a C# Windows Form app that does something (roughly) like: 我有一个C#Windows Form应用程序,其功能(大致)如下:

  1. OpenFileDialog() <-- points to a file path OpenFileDialog()<-指向文件路径
  2. File.Exists() <-- confirms the file path is valid File.Exists()<-确认文件路径有效
  3. File.GetLastWriteTime() <-- checks the file's last modified time File.GetLastWriteTime()<-检查文件的上次修改时间
  4. ZipArchive.CreateEntryFromFile() <-- creates new zip if file has changed ZipArchive.CreateEntryFromFile()<-如果文件已更改,则创建新的zip

I'm trying to get the app working as a UWP app. 我正在尝试使该应用程序作为UWP应用程序工作。 I have successfully gotten it compiled to an APPX and it installs/launches fine. 我已经成功地将其编译为APPX,并且可以很好地安装/启动。 However it seems like all file activity it handles is stuck in a cached/sandbox version of the file system or something. 但是,似乎它处理的所有文件活动都停留在文件系统的缓存/沙盒版本中。

For example: 例如:

  • I select a C:\\Temp\\hello.txt in the app (step #1 above) 我在应用程序中选择一个C:\\ Temp \\ hello.txt(上面的步骤1)
  • Then I modify the text file it in notepad, save and exit 然后我在记事本中修改文本文件,保存并退出
  • Then I trigger my app to execute steps #3 and #4 然后,我触发我的应用执行步骤#3和#4
  • However step #3 claims the file has not changed. 但是,步骤3声称文件没有更改。 This is what makes me think the UWP app is looking at a cached or sandbox set of my filesystem? 这是什么让我认为UWP应用正在查看文件系统的缓存集或沙盒集? Or something else odd happening here? 还是这里发生了其他奇怪的事情?
  • Additionally, if I try to force the app to make the zip regardless of the last modified date, no zip file is actually created when I check the folder - again this makes me wonder if the app is stuck in some sandbox/cache of my file system not the actual file system? 此外,如果无论上次修改日期如何我都试图强制应用制作zip文件,则在我检查文件夹时实际上没有创建任何zip文件-再次使我想知道应用程序是否卡在文件的某些沙箱/缓存中系统不是实际的文件系统?
  • (New) Another interesting clue here is that if I open a Windows Explorer window to C:\\Temp I can see my hello.txt file by itself. (新)这里的另一个有趣线索是,如果我打开Windows资源管理器窗口以访问C:\\ Temp,则可以自己看到我的hello.txt文件。 If I open the openFileDialog() in the UWP app to C:\\Temp I can see my hello.txt file and the hello.zip file it created. 如果在UWP应用中打开C:\\ Temp的openFileDialog(),则可以看到我的hello.txt文件和它创建的hello.zip文件。 So both windows are using C:\\Temp but they show different files!? 因此,两个窗口都使用C:\\ Temp,但是它们显示不同的文件!

Other Notes: 其他说明:

  • UWP app is being created via desktop bridge (makeappx.exe) 通过桌面桥(makeappx.exe)创建UWP应用
  • My AppManifest.xml does have the appropriate broadFileSystemAccess and runFullTrust capabilities declared. 我的AppManifest.xml确实声明了适当的broadFileSystemAccess和runFullTrust功能。
  • I have set the app to be allowed file system access in the File System Privacy Settings dialog in Windows 10. 我已在Windows 10的``文件系统隐私设置''对话框中将应用程序设置为允许文件系统访问。
  • The app works perfectly fine when running as an class *.exe (not a UWP/Appx) 该应用程序作为类* .exe(不是UWP / Appx)运行时运行良好

The desktop bridge capture and redirects file writes to folders that are part of the package. 桌面桥将捕获文件并将文件写入重定向到该软件包的一部分中。 You can read more about this in the official docs . 您可以在官方文档中阅读有关此内容的更多信息。 The purpose is to allow the operating system to clean up those files when the app is uninstalled. 目的是允许操作系统在卸载应用程序时清理这些文件。

You should be able to write to a folder that is not part of the package as long as the user has access to this folder though, and you should then be able to see the file in this actual folder in the File Explorer. 只要用户可以访问该文件夹,您就应该能够写出一个不属于软件包的文件夹,然后您应该能够在文件资源管理器中看到该实际文件夹中的文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM