Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Operation not permitted on IsolatedStorageFileStream for CreateFile in isolated storage

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

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

but I am getting exception while doing the same.. which says.

System.IO.IsolatedStorage.IsolatedStorageException: Operation not permitted on IsolatedStorageFileStream

There are no operation performed apart from this operation.

like image 681
user1893772 Avatar asked Dec 12 '12 13:12

user1893772


2 Answers

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

IsolatedStorageFile storageFile = IsolatedStorageFile.GetUserStoreForApplication();
storageFile.CreateDirectory("Html");
storageFile.CreateFile("Html\\index.html");
like image 178
gregstoll Avatar answered Nov 07 '22 00:11

gregstoll


I had the same problem and it was the 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)
    {
    }
like image 25
Eric Avatar answered Nov 07 '22 01:11

Eric