how to move the file from one system to another system over a network using c#?

Posted by Prabu_Spark under ASP.NET on 5/3/2013 | Points: 10 | Views : 1089 | Status : [Member] | Replies : 1
Hi sir,
Tell me the steps to move the file from one system to another system over a network using c#. I developed using c# windows application, its working fine in local file transfer from localdisk C: drive to d: drive. But if i put ipaddress like "\\\c$\prabu1", it will not move the file to that destination []. I attached the code for your reference. Give me a valuable feedback with the proper solution.


private void Form1_Load(object sender, EventArgs e)

string source_directory = @"c:\datas";
string destination_directory = @"\\\d$\prabu1";

DirectoryInfo sourceinfo = new DirectoryInfo(source_directory);
DirectoryInfo destinationinfo = new DirectoryInfo(destination_directory);

if (sourceinfo.Exists)
string s1 = sourceinfo.FullName;
string d1 = destinationinfo.FullName;
if (Directory.GetFiles(s1).Length > 0 && Directory.GetDirectories(s1).Length == 0)
if (destinationinfo.Exists)
string s = sourceinfo.FullName;

foreach (var filenames in Directory.GetFiles(s1))
//File.Move(str, Path.Combine(dir, Path.GetFileName(str)));

string source_location = filenames;

string prabu = Path.GetFileName(source_location);

string myFile = source_location;
string fileToCopy = destination_directory+"\\"+prabu;

if (File.Exists(fileToCopy))

File.Move(myFile, fileToCopy);



notifyIcon1.BalloonTipText = "No such directory exists in that location";
notifyIcon1.Visible = true;
notifyIcon1.ShowBalloonTip(300, "Notify Icon", "No such directory exists in that location", ToolTipIcon.Error);
//MessageBox.Show("No such directory exists in that location", "Folder not found", MessageBoxButtons.OK, MessageBoxIcon.Error);


With regards,


Posted by: Bageshkumarbagi on: 6/21/2013 [Member] Starter | Points: 25


try with this

Bagesh Kumar Singh

Bagesh Kumar Singh
Mark as answer if you have been satisfied

Prabu_Spark, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response