Reputation: 393
How to move file from one server to another server? Plz help When user uploading the excel file i am moving that file to another server this is the code i am using.....
string destFilename = @"\\192.168.1.2" + @"\\xyz\\xyz1\\" +
fileName + "";
System.IO.File.Copy(filePath, destFilename);
Upvotes: 3
Views: 7404
Reputation: 6953
Your destination path is wrong it would turn out to be
\\192.168.1.2\\sabre\\Mapping Rules Upload\\<filename>
you need 1 slash in each directory seperator
You either need
string destFilename = @"\\192.168.1.2" + @"\sabre\Mapping Rules Upload\" + fileName + "";
or if you remove the "@" then you need to escape each "\" with another "\"
string destFilename = "\\\\192.168.1.2" + "\\sabre\\Mapping Rules Upload\\" + fileName + "";
The @ sign just saves you escaping chars that require escaping in a string!
EDIT: I am presuming that in your code fileName and filePath are set correctly!
HTH
OneSHOT
Upvotes: 2
Reputation: 7889
Not sure exactly what you want, but here is a sample that transfers files using webservices https://web.archive.org/web/1/http://articles.techrepublic%2ecom%2ecom/5100-10878_11-5805105.html
Upvotes: 0