Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I use:</p> <pre><code>private bool CreateFTPDirectory(string directory) { try { //create the directory FtpWebRequest requestDir = (FtpWebRequest)FtpWebRequest.Create(new Uri(FtpURI+"/"+directory)); requestDir.Method = WebRequestMethods.Ftp.MakeDirectory; requestDir.UsePassive = true; requestDir.UseBinary = true; requestDir.KeepAlive = false; //requestDir.UseDefaultCredentials = true; requestDir.Credentials = new NetworkCredential(UserId, Password); requestDir.Proxy = WebRequest.DefaultWebProxy; requestDir.Proxy.Credentials = CredentialCache.DefaultNetworkCredentials; FtpWebResponse response = (FtpWebResponse)requestDir.GetResponse(); Stream ftpStream = response.GetResponseStream(); ftpStream.Close(); response.Close(); return true; } catch (WebException ex) { FtpWebResponse response = (FtpWebResponse)ex.Response; if ((response.StatusCode == FtpStatusCode.ActionNotTakenFileUnavailable) || (((int)response.StatusCode)==521)) { response.Close(); return true; } else { response.Close(); return false; } } } </code></pre> <p>This has the side effect of creating the directory as well. If it already exists you get a 521 result returned which isn't defined in the .NET Enum.</p> <p>When you connect to an FTP server you might specify the Uri as "ftp//ftp.domain.com/somedirectory" but this translates to: "ftp://ftp.domain.com/homedirectoryforftp/somedirectory". To be able to define the full root directory use "ftp://ftp.domain.com//somedirectory" which translates to //somedirectory on the machine.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload