Xamarin.Andorid中的读写CSV操作,原代码:
if (!File.Exists(fullPath))
{
File.CreateText(fullPath);
}
if (fs == null || fs.CanWrite == false)
{
FileStream fs = new FileStream(fullPath, System.IO.FileMode.Append, System.IO.FileAccess.Write);
StreamWriter sw = new StreamWriter(fs, System.Text.Encoding.UTF8);
}
运行出错,错误提示“System.IO.IOException: Sharing violation on path......”
解决方法:
代码修改为:File.CreateText(fullPath).Dispose();