using System;
using System.IO;
using System.Net;
using System.Windows.Forms;
namespace ConsoleApplication1
{
partial class Program
{
//usage: CreateRemoteDirectory("ftp://myftp.com",
// "anonymous", "myemail@mydomain.com",
// "newfolder")
static void CreateRemoteDirectory(string remotePath,
string userName, string password, string newFolder)
{
FtpWebRequest request = (FtpWebRequest)
FtpWebRequest.Create(remotePath + "/" + newFolder);
request.Credentials = new NetworkCredential(
userName, password);
request.Method =
WebRequestMethods.Ftp.MakeDirectory;
try
{
FtpWebResponse response = (FtpWebResponse)
request.GetResponse();
}
catch (WebException ex)
{
MessageBox.Show(ex.Message,
ex.GetType().ToString());
}
catch (Exception ex)
{
MessageBox.Show(ex.Message,
ex.GetType().ToString());
}
}
}
}
|