Access file on remote machine using C#

Example and information to access file on remote machine using C#

Here is the simple example to access the file on remote machine and copy it to local machine.


if (!File.Exists(localFilePath))

{

        if (!File.Exists("\\\\\\NeartoME\\sharefolder"))

            throw new Exception(localFilePath + "and" + \\NeartoME\sharefolder + "files not found.");

        else

        File.Copy("\\\\\\NeartoME\\sharefolder, localFilePath);

}

You have to make sure that you have the read permission on the complete path you have specified otherwise though file exists it will throw exception that file not found.

Regards,
Megha

    

By Perry    Popularity  (5753 Views)