private void _CreateDirectory(String host, String path, String CurrentPath, String username, String password)
{
try
{
WebRequest request = WebRequest.Create(host + "/" + CurrentPath);
request.Method = WebRequestMethods.Ftp.MakeDirectory;
request.Credentials = new NetworkCredential(username, password);
request.Proxy = null;
WebResponse response = request.GetResponse();
}
catch
{
// Guess something should happen here
}
int pos = path.IndexOf("/");
if (pos != path.Length - 1)
{
path = path.Substring(pos + 1, path.Length - (pos + 1));
int ipos = path.IndexOf("/");
CurrentPath += "/" + path.Substring(0, ipos);
_CreateDirectory(host, path, CurrentPath, username, password);
}
}
public void CreateDirectory(String path, String host, String username, String password)
{
if (!(path.ToCharArray()[path.Length - 1] == '/'))
path += "/";
int pos = path.IndexOf("/");
String folder = path.Substring(0, pos);
_CreateDirectory(host, path, folder, username, password);
}