【发布时间】:2013-11-22 05:45:26
【问题描述】:
我必须在 c 驱动器的特定路径上写入文件,我使用以下代码给出上述错误不支持给定路径的格式。
我的路径值为 D:\Ea\10\rep\Demo.txt
System.IO.File.WriteAllText(path, string.Empty);
StreamWriter file2 = new StreamWriter(path, true);
file2.WriteLine("Demo");
file2.Close();
if (System.IO.File.Exists(path))
System.IO.File.Copy(path, @"D:\Demo.htm", true);
【问题讨论】:
-
我的路径值为D:\Ea\10\rep\Demo.txt
-
不应该是
@path吗?我认为将您的路径附加到符号 @ 不会有太大作用。 -
@user2996030:你能运行你的代码吗?
-
可能有错别字:您在这里说,您的路径是“d:\eA\...”,并在评论中写下对“d:\eD\...”的访问权限被拒绝。看看那个。
-
我认为这是
@Dylan Corriveau答案下方 cmets 中指定的错字。