强制在Windows Phone 8应用程序中为临时文件和路径创建目录



我有一个c# Windows Phone 8应用程序,我需要创建一些临时文件。目前,我正在使用以下代码创建必要的临时文件名和路径:

string tempFilename = Path.Combine(Path.GetTempPath(), Path.GetTempFileName());
Uri tempUri = new Uri(tempFilename, UriKind.Absolute);
问题是,当我用以下代码创建文件时:
StorageFile binaryFile = await localFolder.CreateFileAsync(filename, CreationCollisionOption.ReplaceExisting);

操作失败,提示文件未找到异常,因为文件夹路径不存在。如何快速创建所有必要的目录及其下的子目录,以支持临时文件路径,并且在目录树已经存在的情况下不会失败?

下面是一个示例临时文件名和路径:

C:DataUsersDefAppsAppData{28B80680-CB2F-459B-B6AC-A60A9A729868}Temptmp7C9F.tmp

在隔离存储中创建目录只有一种方法:IsolatedStorageFile。创建目录,如果你在windows phone

最新更新