[英]Create txt file outside website root folder with StreamWriter
Is it possible for a web application to write a text file outsite the root folder (like, C:\\test.txt) using the StreamWriter
? Web应用程序是否可以使用
StreamWriter
在根文件夹(例如C:\\ test.txt)的外部写入文本文件? I wasn't able to make it work even with full permissions. 即使具有完全权限,我也无法使其正常运行。
string vRegistro = "Some test";
StreamWriter tex = new StreamWriter(@"\\ICOM\public.txt", true, Encoding.UTF8);
tex.WriteLine(vRegistro);
tex.Close();
\\\\ICOM\\public.txt
will be interpreted as a UNC path, since is starts with a double backslash. \\\\ICOM\\public.txt
将被解释为UNC路径,因为它以双反斜杠开头。
It is not a valic UNC at that. 那不是一个普通的UNC。
Removing a backslash from the start will result in a file called public.txt
being written to the ICOM folder of your application environment's root directory. 从头开始删除反斜杠将导致一个名为
public.txt
的文件被写入应用程序环境根目录的ICOM文件夹中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.