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

后端 未结 6 657
野的像风
野的像风 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:32

    You will have to close the file after editing it.

    var myFile = File.Create(myPath);
    //myPath = "C:\file.txt"
    myFile.Close();
    //closes the text file for eg. file.txt
    //You can write your reading functions now..
    

    After closing it you can again use it(for reading)

提交回复
热议问题