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

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



Code:
**************

private void Form1_Load(object sender, EventArgs e)
{

string source_directory = @"c:\datas";
string destination_directory = @"\\192.168.10.37\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.Delete(fileToCopy);
}

File.Move(myFile, fileToCopy);


}
}
}



}

else
{
//this.Close();
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,
J.Prabu.
[Email:prbspark@gmail.com]



Responses

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

Up
0
Down
hi

try with this
http://innodesign.over-blog.com/article-file-transfer-using-c-53823615.html

Thanks,
Bagesh Kumar Singh

Thanks,
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