Create a folder in remote server using c# code


Create a folder in remote server.

Make sure that you have write permission on remote location you have specified. This example also creates a file under that folder.


public class CreateFileOrFolder
{
static void Main()
{
string folderName = "\\\\domain\\site\\folderlocation\\foldername";

System.IO.Directory.CreateDirectory(folderName);

// Create a new file name. This example generates
// a random string.
string newFileName = System.IO.Path.GetRandomFileName();

// Combine the new file name with the path
newPath = System.IO.Path.Combine(folderName, newFileName);

}
}


Comments

Guest Author: prasad buruga28 Jun 2012

Hi,
I want to create folder in remote server.I know the remote server Name, Password, Domain as of know i am using this code

String GetApplicationPath = @"\\\\ServerName\\MyFolder\\";//
System.IO.Directory.CreateDirectory(GetApplicationPath);

it gives error message as "Login failure: unknown user name or bad password."

please.help



  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: