C# 在c中写入文本文件时发生IoException#
我有一个文本文件,我需要根据正则表达式匹配更新它,但是当我的程序试图在文本文件中写入一行时,它给出了以下错误C# 在c中写入文本文件时发生IoException#,c#,regex,text-files,file-handling,C#,Regex,Text Files,File Handling,我有一个文本文件,我需要根据正则表达式匹配更新它,但是当我的程序试图在文本文件中写入一行时,它给出了以下错误 The process cannot access the file 'D:\Archieve\20140123.text' because it is being used by another process. 这是我的密码 哪里出错了?使用File.Create(textfilename.Close() 正如错误消息所示,创建文件不需要单独的指令。 StreamWriter将处理
The process cannot access the file 'D:\Archieve\20140123.text' because it is being used by another process.
这是我的密码
哪里出错了?使用File.Create(textfilename.Close()代码>
正如错误消息所示,创建文件不需要单独的指令。
StreamWriter将处理它:下面是您所使用的构造函数的描述
> Initializes a new instance of the StreamWriter class for the specified
> file by using the default encoding and buffer size. If the file
> exists, it can be either overwritten or appended to. If the file does
> not exist, this constructor creates a new file.
TextWriter tsw = new StreamWriter(textfilename,true);
> Initializes a new instance of the StreamWriter class for the specified
> file by using the default encoding and buffer size. If the file
> exists, it can be either overwritten or appended to. If the file does
> not exist, this constructor creates a new file.