C# 拒绝访问新创建的文件夹
我正在将网络驱动器上的文件写入新文件夹C# 拒绝访问新创建的文件夹,c#,.net-4.0,asp.net-4.0,C#,.net 4.0,Asp.net 4.0,我正在将网络驱动器上的文件写入新文件夹 string directory=@"\\dir\test\" string folderName = "testFolder " + DateTimeOffset.Now.UtcDateTime.ToString().Replace("/","-").Replace(":","-"); string newPath = Path.Combine(directory, folderName); if (!Directory.Exists
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);
}
}
在线:使用(System.IO.FileStream fs=File.Create(newPath))
-它错误地说:
无法访问路径“\dir\test\testFolder 3-19-2012 11-58-43 PM”
否认
我必须使用DirectorySecurity创建一个允许读写的目录。仍然收到一个错误
我一直遵循以下主题创建文件夹和文件:
我可以毫无问题地写入目录
@“\\dir\test\”
。您对目录和文件使用相同的新路径