0

フォルダー A があり、それを自分のコンピューターからネットワーク上のサーバーに移動したいと考えています。

試してみましDirectory.Move(A,Server)たが、ルートが同じではないため、機能しません。

File.Copy(A,Server)フォルダーは読み取り専用であり、アクセス許可を変更できないため、機能しません。

前もって感謝します。

コードを含む編集

string copyFrom = @"folder";
string copyTo = @"\\server\Libraries\Documents";
string destinationPath = Path.Combine(copyTo, Path.GetFileName(copyFrom));
File.Copy(copyFrom, destinationPath);

それが私が現在使用しているコードです。

編集2

私のコンピューターとサーバーは異なるドメインにあります。

4

1 に答える 1

1

@Tigran が示唆したように、xcopy (または必要に応じて robocopy) で cmd を使用できます。

これを使用してみてください:

ProcessStartInfo Info = new ProcessStartInfo(); 
Info.Arguments = "/C xcopy C:\A \\server\A /I /E /Y"; 
Info.WindowStyle = ProcessWindowStyle.Hidden; 
Info.CreateNoWindow = true; 
Info.FileName = "cmd.exe"; 
Process.Start(Info);
于 2012-06-20T10:39:35.320 に答える