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.
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");
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)
{
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With