Question

How can I remove 1 character off the end of a certain file in IsolatedStorage?

The code I have so far is:

var appStorage = IsolatedStorageFile.GetUserStoreForApplication();

using (var writer = new StreamWriter(appStorage.OpenFile("trailCount", FileMode.Truncate, FileAccess.Write)))
{
    writer.Write(1);
}

However It doesn't seem to work.

Thanks

Était-ce utile?

La solution

If you want to remove the last character you could do the following:

writer.BaseStream.SetLength(writer.BaseStream.Length - 1);

Additionaly, when opening the file, use FileMode.Open, otherwise whole file will be truncated.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top