I guess it should be pretty straigh forward,you can use the following snippet to create directories on FTP and call the CreateDirectoryOnFtp method wherever you want to make a Directory:
static void CreateDirectoryOnFTP(String inFTPServerAndPath, String inUsername, String inPassword, String inNewDirectory)
{
// Step 1 - Open a request using the full URI, ftp://ftp.server.tld/path/file.ext
FtpWebRequest request = (FtpWebRequest)FtpWebRequest.Create(inFTPServerAndPath + "/" + inNewDirectory);
// Step 2 - Configure the connection request
request.Credentials = new NetworkCredential(inUsername, inPassword);
request.UsePassive = true;
request.UseBinary = true;
request.KeepAlive = false;
request.Method = WebRequestMethods.Ftp.MakeDirectory;
// Step 3 - Call GetResponse() method to actually attempt to create the directory
FtpWebResponse makeDirectoryResponse = (FtpWebResponse)request.GetResponse();
}
A fundamental rule in technology says whatever can be done will be done
Marked as answer by Angie xu - MSFT on Jan 25, 2013 12:04 AM
How to create multiple folders on Ftp server using C#
There is a discussion about creating folder on ftp below, at the same time you could also learn deeply about that, if folder already exists how to make it over write the existing folder.
ahujanisha16
Member
1 Points
19 Posts
how to create multiple folders on Ftp server using C#
Jan 17, 2013 08:06 AM|LINK
How to create multiple folders on Ftp server using C#
santosh.jagd...
Star
7625 Points
1454 Posts
Re: how to create multiple folders on Ftp server using C#
Jan 17, 2013 10:20 AM|LINK
using System; using System.Net; class Test { static void Main() { WebRequest request = WebRequest.Create("ftp://host.com/directory"); request.Method = WebRequestMethods.Ftp.MakeDirectory; request.Credentials = new NetworkCredential("user", "pass"); using (var resp = (FtpWebResponse) request.GetResponse()) { Console.WriteLine(resp.StatusCode); } } }more help http://forums.asp.net/t/1867388.aspx/1?How+to+copy+folder+from+local+machine+to+FTP+server+
MCP
ankit.sri
Contributor
2042 Points
410 Posts
Re: how to create multiple folders on Ftp server using C#
Jan 17, 2013 10:22 AM|LINK
I guess it should be pretty straigh forward,you can use the following snippet to create directories on FTP and call the CreateDirectoryOnFtp method wherever you want to make a Directory:
static void CreateDirectoryOnFTP(String inFTPServerAndPath, String inUsername, String inPassword, String inNewDirectory) { // Step 1 - Open a request using the full URI, ftp://ftp.server.tld/path/file.ext FtpWebRequest request = (FtpWebRequest)FtpWebRequest.Create(inFTPServerAndPath + "/" + inNewDirectory); // Step 2 - Configure the connection request request.Credentials = new NetworkCredential(inUsername, inPassword); request.UsePassive = true; request.UseBinary = true; request.KeepAlive = false; request.Method = WebRequestMethods.Ftp.MakeDirectory; // Step 3 - Call GetResponse() method to actually attempt to create the directory FtpWebResponse makeDirectoryResponse = (FtpWebResponse)request.GetResponse(); }Angie xu - M...
All-Star
18045 Points
1550 Posts
Microsoft
Re: how to create multiple folders on Ftp server using C#
Jan 21, 2013 07:20 AM|LINK
Hi ahujanisha
There is a discussion about creating folder on ftp below, at the same time you could also learn deeply about that, if folder already exists how to make it over write the existing folder.
Create folder on ftp
hope it helps you,
Kind regards
Feedback to us
Develop and promote your apps in Windows Store