写入文本文件C#

时间:2017-05-13 17:24:49

标签: c# unity3d streamwriter sharing-violation

    void Update(){
    StreamWriter writer = new StreamWriter(Application.dataPath + @"/SaveFiles/ControlStick.txt", true);
    writer.WriteLine(inputVector); //+ "," + DateTime.Now.TimeOfDay);
}

这是相关代码。 我需要写一个统一文件而不会一次又一次地覆盖这些行。

这是我的具体错误。 IOException:路径G:\ Physics Platformer \ Assets \ SaveFiles \ ControlStick.txt上的共享冲突 System.IO.FileStream..ctor(System.String路径,FileMode模式,FileAccess访问,FileShare共享,Int32 bufferSize,布尔匿名,FileOptions选项)(在/ Users / builduser / buildslave / mono / build / mcs / class / corlib /System.IO/FileStream.cs:320) System.IO.FileStream..ctor(System.String路径,FileMode模式,FileAccess访问,FileShare共享) (wrapper remoting-invoke-with-check)System.IO.FileStream:.ctor(string,System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare) System.IO.StreamWriter..ctor(System.String path,Boolean append,System.Text.Encoding encoding,Int32 bufferSize)(at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.IO/ StreamWriter.cs:124) System.IO.StreamWriter..ctor(System.String path,Boolean append) (wrapper remoting-invoke-with-check)System.IO.StreamWriter:.ctor(string,bool) VirtualJoystick.Update()(在Assets / UBX-master / UBX-master / VirtualJoystick.cs:51) 为了解释,我使用Application.dataPath来获取我的Unity游戏在导出和安装时的安装路径。输入向量是Vector3。

0 个答案:

没有答案