2015-03-03 101 views

回答

2

在您的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类是您访问以下位置的方式。

  • CameraRoll
  • DocumentsLibrary
  • 家庭组
  • MediaServerDevices
  • MusicLibrary
  • PicturesLibrary
  • 播放列表
  • RemovableDevices
  • SavedPictures
  • VideosLibrary

KnownFolders class on MSDN