0
我试图通过使用获得的临时目录:Path.GetTempPath()在Windows应用商店的应用程序不可用
string tempFolder = System.IO.Path.GetTempPath();
但是,这种方法不存在。尽管我可以在智能感知中看到所有其他方法。
为什么该方法不可用。是否有另一种方式获取Windows应用商店应用中的临时文件夹位置?
我试图通过使用获得的临时目录:Path.GetTempPath()在Windows应用商店的应用程序不可用
string tempFolder = System.IO.Path.GetTempPath();
但是,这种方法不存在。尽管我可以在智能感知中看到所有其他方法。
为什么该方法不可用。是否有另一种方式获取Windows应用商店应用中的临时文件夹位置?
在您的ApplicatonData存储中创建临时文件。您必须使用guid或时间戳生成您自己的文件名。
Windows.Storage.StorageFolder temporaryFolder = ApplicationData.Current.TemporaryFolder;
StorageFile sampleFile = await temporaryFolder.CreateFileAsync("dataFile.txt", CreationCollisionOption.ReplaceExisting);
await FileIO.WriteTextAsync(sampleFile, formatter.Format(DateTime.Now));
一个Windows Store应用是沙箱,这样你就有望读写您的沙盒应用程序文件夹内的文件夹。你可能无法写入传统的临时文件夹C:\Windows\TEMP
,因为你可能想要,而且你运气不好。您有权访问应用程序文件夹外的其他几个位置,但在大多数情况下,您的访问受到限制。
KnownFolders类是您访问以下位置的方式。