简体   繁体   English

UWP应用程序有默认文件夹吗?

[英]Is there default folder for UWP application?

For Windows application we have default folder, where .exe file is located. 对于Windows应用程序,我们具有.exe文件所在的默认文件夹。 If we put some file to this folder we can open it in application, just specifying file name without path. 如果我们将一些文件放到该文件夹​​中,则可以在应用程序中打开它,只需指定没有路径的文件名。

But for UWP, it's different. 但是对于UWP,则有所不同。 We have KnownFolders , to which application has access. 我们有KnownFolders ,应用程序可以访问。 And I need specify in which KnowFolder my file is located. 我需要指定我的文件位于哪个KnowFolder中。

But I want just put file to some location and open it from application, not specify folder type or folder path, the same way I use default folder for Windows application. 但是我只想将文件放在某个位置并从应用程序中打开它,而不是指定文件夹类型或文件夹路径,就像我对Windows应用程序使用默认文件夹一样。

Is it possible? 可能吗?

For security reason the installed folder is readonly so " just specifying file name without path" is not possible in UWP technology. 出于安全原因,已安装的文件夹为只读文件夹,因此在UWP技术中“仅指定没有路径的文件名”是不可能的。

The recommend folder for your scenario is LocalFolder. 针对您的方案的推荐文件夹为LocalFolder。 Which is also the recommend storage place for settings, please have a look at official doc: Store and retrieve app data . 这也是建议的设置存储位置,请查看官方文档: 存储和检索应用程序数据 Local folder is not complex, just a line of code: 本地文件夹并不复杂,只需一行代码:

Windows.Storage.ApplicationData.Current.LocalFolder

You can treat it as the default folder for your common data. 您可以将其视为公用数据的默认文件夹。

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

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