Operation not permitted on IsolStorageFileStream for CreateFile in isolated storage

I am trying to create a file in isolated storage using the following code,

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

but I get an exception by doing the same .. that says.

System.IO.IsolatedStorage.IsolatedStorageException: Operation not allowed on IsolStorageFileStream

Operations are not performed separately from this operation.

+6
source share
2 answers

You probably need to create an Html directory first. Since IsolatedStorageFile.CreateDirectory () will succeed if the directory already exists, you can simply do

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

I had the same problem and it was a directory path.

This code worked to write to a file.

 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) { } 
+1
source

All Articles