System.IO.IOException: 'The process cannot access the file '@.txt' because it is being used by another process.'

后端 未结 6 649
野的像风
野的像风 2021-01-11 13:15

I am new to programming and I have a question. If I have two functions, one creates a text file and writes into it, while the other opens the same text file and reads from i

6条回答
  •  梦谈多话
    2021-01-11 13:50

    Create a file and then close it. After can save data into that file. I did as below.

    if (!File.Exists(filePath))
    {
        File.Create(filePath).Close();
    }
    File.WriteAllText(filePath, saveDataString)
    

提交回复
热议问题