我找不到临时文件夹在哪里添加临时文件。 我怎么找到?
答案 0 :(得分:1)
您只需创建自己的文件夹并管理内容:
private void SaveTempFile(string fileName, object data)
{
var storage = IsolatedStorageFile.GetUserStoreForApplication();
if (storage.DirectoryExists("temp") == false)
storage.CreateDirectory("temp");
fileName = Path.Combine("temp", fileName);
using (var fileStream = new IsolatedStorageFileStream(fileName, FileMode.Create, storage))
{
//Write the data
using (var isoFileWriter = new StreamWriter(fileStream))
{
// write your data in the format of your choice
}
}
}
随时删除文件
public void DeleteTempFile(string fileName)
{
try
{
var storage = IsolatedStorageFile.GetUserStoreForApplication();
if (storage.DirectoryExists("temp") == false) return;
fileName = Path.Combine("temp", fileName);
if (storage.FileExists(fileName))
{
storage.DeleteFile(fileName);
}
}
catch (Exception) { }
}
答案 1 :(得分:0)
在Windows Phone上没有为app准备的那种文件夹。您必须自己创建它并在不再需要时管理清除那里的内容表单。但是,在卸载应用程序时,您无需担心删除该文件 - 然后从隔离存储中删除整个应用程序文件夹。