0
我正在将网络驱动器上的文件写入新文件夹。访问新创建的文件夹被拒绝
string [email protected]"\\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))
- 它的错误出来说:
访问路径 '\目录\测试\ testFolder 2012年3月19日下午11-58-43' 是 拒绝。
我必须创建一个允许读写的DirectorySecurity目录。仍然收到错误。
我一直在关注以下主题创建文件夹和文件: http://msdn.microsoft.com/en-us/library/as2f1fez.aspx
我能写的目录@"\\dir\test\"
没有问题。
UGH。该回家了。你是对的 - 非常感谢! – user194076 2012-03-20 00:14:02