Reputation: 571
I want to make a WinForms Application that can copy files over a LAN. Using File.Copy seems a straightforward way to do this. The example given here shows how to copy a file to a different directory on the same computer. How can I use File.Copy to copy files from one computer to another which belongs to the same LAN?
Upvotes: 6
Views: 5932
Reputation: 19
' code in Vb , convert it into C#
Dim findDirectory = "D:\UOLQserver\Data\Sound\"
Dim Y_N = System.IO.Directory.Exists(findDirectory)
If Y_N = True Then
Else
Directory.CreateDirectory(findDirectory)
End If
Dim MyFilename1 = findDirectory & "\" & Today.Day & "-" & Today.Month & "-" & Today.Year & "-" & tineNow & "-" & Today.Minute & ".wav"
FileCopy("\\SERVER\D$\UOLQserver\Data\Sound\test.wav", MyFilename1)
Upvotes: 0
Reputation: 10108
you can try
File.Copy(@"\\server\sourceFileFolder\file1", @"\\server2\destinationFileFolder\file1");
also make sure to use UNC path.. here are some references. - Link - Link - Link
Upvotes: 4
Reputation: 1067
Something like this
File.Copy(
"C:\path\yourfile.txt",
"\\remote_hostname\path\destinationfile.txt");
Upvotes: 2