URI格式不支持 [英] URI Format Not supported

查看:157
本文介绍了URI格式不支持的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将文件从服务器复制到本地系统应用程序文件夹,但它显示了System.IO.Path.NormalizePath等不支持的异常URI格式....



错误可能在System.IO.File.Copy(sourceFile,destFile,true)



这里是代码



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 = "http://www.mywebsite.com/temp/New 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.Directory.CreateDirectory(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);


               }


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

           }


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



       }

推荐答案

Hello Akmal,



我认为File.Copy不支持 file:// 以外的URL格式。错误发生在您的源路径中。使用此方法在具有读/写权限的本地文件夹或共享文件夹之间进行复制。



问候,
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.

Regards,


System.IO.File 不支持从Internet下载。要从Internet下载文件,您应该使用 WebClient.DownloadFile
The System.IO.File does not support downloading from the Internet. To download a file from the Internet, you should use WebClient.DownloadFile instead.


这篇关于URI格式不支持的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆