如何在上传文件时使用webclient创建目录

如何在上传文件时使用webclient创建目录

本文介绍了如何在上传文件时使用webclient创建目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我正在尝试下面的代码,在远程服务器上传文档,但它显示错误
"给定不支持路径格式。"




  using(WebClient client = new WebClient())

{


                  client.Credentials =新的NetworkCredential(用户名,密码);


             &NBSP ;    Directory.CreateDirectory(@" https://Sample.com/Folders/Test Folder /");    
//此处显示错误


     ;              client.UploadFile(QUOT; HTTPS://Sample.com/Folders/Test文件夹/"," POST",@" C:\\Sample Document.docx");   &NBSP ;            


  }



如何使用webclient创建必要的目录?


-TIA




解决方案


Hi,

I am trying with below code, to Upload a document in remote server, but it shows an Error"The given path's format is not supported."


 using (WebClient client = new WebClient())
{

                  client.Credentials = new NetworkCredential(UserName, Password);

                  Directory.CreateDirectory(@"https://Sample.com/Folders/Test Folder/");    //Error shown here

                  client.UploadFile("https://Sample.com/Folders/Test Folder/", "POST" , @"C:\\Sample Document.docx");                

  }

How can I create the necessary directories with webclient ?

-TIA


解决方案


这篇关于如何在上传文件时使用webclient创建目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 05:08