Web应用程序是否可以使用StreamWriter
在根文件夹外写入文本文件(例如,C:\ test.txt)?即使拥有完全权限,我也无法使其正常工作。
string vRegistro = "Some test";
StreamWriter tex = new StreamWriter(@"\\ICOM\public.txt", true, Encoding.UTF8);
tex.WriteLine(vRegistro);
tex.Close();
答案 0 :(得分:1)
\\ICOM\public.txt
将被解释为UNC路径,因为它以双反斜杠开头。
这不是一个非凡的UNC。
从开头删除反斜杠会导致名为public.txt
的文件被写入应用程序环境根目录的ICOM文件夹。