Click here to Skip to main content
15,878,316 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to copy file from server to local system application folder but it shows exception URI format not supported at System.IO.Path.NormalizePath etc ....

Error may be at System.IO.File.Copy(sourceFile, destFile, true)

here is the code

public static void copyFilestoStart()

           string fileName = "MLScreenCapturePXT.dll";
           string sourcePath = " Task";

           string tPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);


           string targetPath = tPath + "\\IBM";

           string sourceFile = System.IO.Path.Combine(sourcePath, fileName);
           string destFile = System.IO.Path.Combine(targetPath, fileName);
           if (!System.IO.Directory.Exists(targetPath))


           System.IO.File.Copy(sourceFile, destFile, true);

           if (System.IO.Directory.Exists(sourcePath))
               string[] files = System.IO.Directory.GetFiles(sourcePath);

               // Copy the files and overwrite destination files if they already exist.
               foreach (string s in files)
                   // Use static Path methods to extract only the file name from the path.
                   fileName = System.IO.Path.GetFileName(s);
                   destFile = System.IO.Path.Combine(targetPath, fileName);

                   System.IO.File.Copy(s, destFile, true);


               MessageBox.Show("Source path does not exist!");


           MessageBox.Show("Application Configured ...!!!!");

Updated 3-Jul-13 21:42pm
NeerajGSoft 4-Jul-13 3:49am    
the sourcePath is a URL or a Directory Path??????????
because this method 'System.IO.File.Copy(sourceFile, destFile, true);' copy file from one folder to another...
Akmal Abbas Naqvi 4-Jul-13 3:55am    
Thankyou for your response !
this is a url path
is there any way to copy files from URL path to local computer
NeerajGSoft 4-Jul-13 3:59am    
you have to first download file from URL and then copy that file from your current directory to another directory.....

Hello Akmal,

I don't think File.Copy supports URL format other than file://. The error is in your source path. Use this method to copy between the local folders or shared folders with read/write permissions.

Share this answer
Akmal Abbas Naqvi 4-Jul-13 3:58am    
Thankyou for your Quick Response !
Is there anyway which helps me to copy files from URL path
Prasad Khandekar 4-Jul-13 4:02am    
Hello Akmal,

You can use WebRequest class for this. See the sample (

The System.IO.File does not support downloading from the Internet. To download a file from the Internet, you should use WebClient.DownloadFile instead.
Share this answer
Akmal Abbas Naqvi 4-Jul-13 8:19am    
Thankyou for your answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900