6

나는 다음과 같은 코드를 사용하여 격리 된 저장소에 파일을 만들려고하고 있어요에 CreateFile에 대한 IsolatedStorageFileStream에 허용되지하지만 같은 일을하는 동안 예외를 얻고있다.작동</p> <pre><code>IsolatedStorageFile storageFile = IsolatedStorageFile.GetUserStoreForApplication(); storageFile.CreateFile("Html\index.html"); </code></pre> <p>, 격리 된 저장소

System.IO.IsolatedStorage.IsolatedStorageException : 작동은 더 작업이이 작업을 별도로 수행하지 있습니다

IsolatedStorageFileStream

에 허용되지 않습니다.

+0

먼저 'Html' 폴더를 만들었습니까? 또한,'index.html' 파일이 아직 존재하지 않습니까? –

답변

3

먼저 Html 디렉토리를 만들어야 할 수도 있습니다. 디렉토리가 이미 존재하는 경우 IsolatedStorageFile.CreateDirectory()이 성공으로, 당신은 단지 저도 같은 문제를 겪고 있으며 디렉토리 경로이었다

IsolatedStorageFile storageFile = IsolatedStorageFile.GetUserStoreForApplication(); 
storageFile.CreateDirectory("Html"); 
storageFile.CreateFile("Html\\index.html");
+0

파일을 만들기 전에 "isf.FileExists()"검사를하고 있지만 여전히 문제가 있습니다. 또한 파일을 만들기 전에 Html 폴더를 만들었습니다. 동일한 예외가 발생했습니다 - mscorlib.ni.dll에서 'System.IO.IsolatedStorage.IsolatedStorageException'유형의 예외가 발생했지만 사용자 코드에서 처리되지 않았습니다. ---- – user1893772

+0

InnerException에있는 것이 있습니까? IsolatedStorageException? – gregstoll

1

할 수 있습니다.

이 코드는 파일에 쓰는 데 효과적입니다.

IsolatedStorageFile myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication(); 
    var folder = ApplicationData.Current.LocalFolder; 
    string folderfilename = folder.Path + "\\" + fileName; 
    try 
    { 
     StreamWriter writeFile = new StreamWriter(new IsolatedStorageFileStream(folderfilename, FileMode.OpenOrCreate, myIsolatedStorage)); 
     writeFile.WriteAsync(content); 
     writeFile.Close(); 
    } 
    catch (Exception ex) 
    { 
    }