![](/img/trans.png)
[英]Saving complex object to IsolatedStorage as XML file in Windows Phone (C#)
[英]Windows phone - C# - Truncating file(s) in IsolatedStorage
如何在IsolatedStorage中刪除某個文件末尾的1個字符?
到目前為止,我的代碼是:
var appStorage = IsolatedStorageFile.GetUserStoreForApplication();
using (var writer = new StreamWriter(appStorage.OpenFile("trailCount", FileMode.Truncate, FileAccess.Write)))
{
writer.Write(1);
}
但是,它似乎不起作用。
謝謝
如果要刪除最后一個字符,可以執行以下操作:
writer.BaseStream.SetLength(writer.BaseStream.Length - 1);
另外,打開文件時,請使用FileMode.Open
,否則整個文件將被截斷。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.