如果指定位置,我正在检查文件是否存在,如果是,我将用 ' 替换单引号。为此,我使用的是 WriteAllText 方法。据我所知,WriteAllText 将用于Create file and write the text and close it, target file is already exists, it will be overwritten
.
我不知道为什么我System.IOException
在使用时得到
var file = AppDomain.CurrentDomain.BaseDirectory + "test";
if (Directory.Exists(file))
{
string text = File.ReadAllText(file + "\\test.txt");
text = text.Replace("'", "'");
File.WriteAllText(file + "\\test.txt", text);
}
注意:我正在使用这个内部Application_BeginRequest
方法。
建议我如何避免这种异常?