【发布时间】:2012-03-20 00:07:00
【问题描述】:
我正在将网络驱动器上的文件写入新文件夹。
string directory=@"\\dir\test\"
string folderName = "testFolder " + DateTimeOffset.Now.UtcDateTime.ToString().Replace("/","-").Replace(":","-");
string newPath = Path.Combine(directory, folderName);
if (!Directory.Exists(newPath))
{
Directory.CreateDirectory(newPath);
}
if (!File.Exists(newPath))
{
using (System.IO.FileStream fs = File.Create(newPath))
{
fs.Write(data, 0, data.Length);
}
}
在线:using (System.IO.FileStream fs = File.Create(newPath)) - 错误提示:
访问路径 '\dir\test\testFolder 3-19-2012 11-58-43 PM' 是 拒绝。
我必须创建一个允许读写的 DirectorySecurity 目录。仍然收到错误。
我一直在关注以下主题来创建文件夹和文件: http://msdn.microsoft.com/en-us/library/as2f1fez.aspx
我可以毫无问题地写入目录@"\\dir\test\"。
【问题讨论】:
标签: c# .net-4.0 asp.net-4.0