2012-03-20 17 views
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)) - と言ってもエラーが出:パス '\ DIR \テスト\のtestFolder 2012年3月19日11-58-43 PM' へ

アクセスが拒否されまし です。

私はDirectorySecurityで読み書きができるディレクトリを作成しました。依然としてエラーが発生します。

私は、フォルダやファイルを作成するには、次のトピックを追ってきた: http://msdn.microsoft.com/en-us/library/as2f1fez.aspx

私は問題なくディレクトリ@"\\dir\test\"に書き込むことができますよ。

答えて

2

ディレクトリとファイルに同じnewPathを使用しています。

+1

UGH。家に帰る時間。あなたは正しい - たくさんのことがあります! – user194076

関連する問題