Reputation: 71
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 ?
Upvotes: 0
Views: 2001
Reputation: 4638
You could try like below
//File Path
string filepath = System.Web.HttpContext.Current.Server.MapPath("~/Folders/Test Folder/");
if (!Directory.Exists(filepath))
{
Directory.CreateDirectory(filepath);
}
Upvotes: 2