System.IO.IOException:共享路径冲突

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了System.IO.IOException:共享路径冲突相关的知识,希望对你有一定的参考价值。

我收到以下共享冲突:

System.IO.IOException: 'Sharing violation on path /data/user/0/android_game.android_game/files/GameSave.txt'

[使用Visual Studio尝试以下代码以在Environment.SpecialFolder.Personal目录中写入/读取文件时

string FilePath = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
FilePath = Path.Combine(FilePath, "GameSave.txt");

StreamWriter savefile = new StreamWriter(FilePath, true);
savefile.WriteLine("test");

StreamReader sr = new StreamReader(FilePath);
Console.WriteLine(sr.ReadLine());
sr.Close();

对于上下文,我只需要一个游戏的基本文本保存文件,就不会与其他应用共享。谢谢您的任何帮助。

答案

找到此线程后找到了它:Sharing violation IOException while reading and writing to file C#

以上是关于System.IO.IOException:共享路径冲突的主要内容,如果未能解决你的问题,请参考以下文章