2011-10-03 7 views
2

我遇到了每次第一次運行應用程序時都會收到IsolatedStorageException('IsolatedFileStorageStream不允許操作「)的問題。隨後運行該應用程序的時間,它工作得很好。我已經嘗試了所有可以找到的用於寫入的打開文件的方法,包括第一次緩存訪問時出現IsolatedStorageException

using (var iso = IsolatedStorageFile.GetUserStoreForApplication()) 
using (IsolatedStorageFileStream file = new IsolatedStorageFileStream(fileName, FileMode.Create, FileAccess.Write, iso)) 
{ 
} 

using(var iso = IsolatedStorageFile.GetUserStoreForApplication()) 
using(IsolatedStorageFileStream file = iso.OpenFile(fileName, FileMode.OpenOrCreate)) 
{ 
} 

以及其他各種重載方法。我所做的沒有任何工作,並且我已經在堆棧溢出的每一個帖子以及我可以找到的每篇博文中都遵循了這些步驟。當我查看輸出時,每次拋出以下例外:

A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll 
A first chance exception of type 'System.Net.WebException' occurred in System.Windows.dll 
A first chance exception of type 'System.Net.WebException' occurred in System.Windows.dll 
A first chance exception of type 'System.IO.DirectoryNotFoundException' occurred in mscorlib.dll 
A first chance exception of type 'System.IO.IsolatedStorage.IsolatedStorageException' occurred in mscorlib.dll 

有沒有人有任何其他想法,爲什麼它會爆炸?我正在使用WP7 7.1 RTM工具。

回答

0

原來,如果你有它有趣的字符的文件名,你會得到一個異常,但後來由於某種原因,接受文件名。

0

試試這個,

if (!myStore.DirectoryExists(directory)) 
{  

    myStore.CreateDirectory(directory);     
    using (IsolatedStorageFile myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication()) 

    {       
     using (var isoFileStream = myIsolatedStorage.CreateFile(directory+"//yourfilename.jpg")) 

     {        
     //her what do you want.... 
     } 

    } 

} 
+0

它的工作對我毫無例外 – Pavan