views:

227

answers:

1

im using c#.net..i want to get the files that are on the server PC to my PC..both the PCs are connected through network.. i have given IP address of that PC in the path...but its not copying the files to my folder. im using the following code ...but its not working..kindly help me out..

File.Copy(Path.GetFileName(sourceFile), Path.GetDirectoryName(targetpath));

in sourceFile i have given IP address + folder path of the server PC and in the targetpath i have given the path of the folder of my PC to which i want to copy the files..

A: 

Wy do you use Path.GetFileName? This function get only file name, not full path. The signature of File.Copy(string sourceFileName, string destFileName) means, that you must use full path to both files.

This code works good:

File.Copy(@"\\server\folder$\test.txt", "test.txt");
Stremlenye