2012-05-31 74 views

回答

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) { } 
} 
0

沒有在Windows Phone的應用程序編寫那種夾。您必須自行創建它,並在不再需要時管理清除內容。但是,當您的應用程序被卸載時,您不需要費心去刪除該文件 - 然後整個應用程序文件夾將從獨立存儲中刪除。

相關問題