Xamarin.Andorid中的讀寫(xiě)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);
}
運(yùn)行出錯(cuò),錯(cuò)誤提示“System.IO.IOException: Sharing violation on path......”
解決方法:
代碼修改為:File.CreateText(fullPath).Dispose();