Make Directory on Ftp!

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • aamersaeed2368
    New Member
    • Dec 2011
    • 13

    Make Directory on Ftp!

    Hi All,

    I am writing a code to make directory on ftp using c# and everything seems right.....But i am getting and error "The remote server returned an error: (550) File unavailable (e.g., file not found, no access)." and i don't know why. I am pasting the code here can anyone help????????

    Code:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Net;
    
    namespace makedirectory
    {
        class Program
        {
            static void Main(string[] args)
            {
                FtpWebRequest request = (FtpWebRequest)FtpWebRequest.Create("ftp://127.0.0.1/" + "NewDirectory");
                request.Credentials = new NetworkCredential("anonymous", "anonymous");
                request.UsePassive = true;
                request.UseBinary = true;
                request.KeepAlive = false;
                Console.WriteLine("Getting the response");
    
                request.Method = WebRequestMethods.Ftp.MakeDirectory;
                
                using (var resp = (FtpWebResponse)request.GetResponse())
                {
                    Console.WriteLine(resp.StatusCode);
                }
    
            }
            
        }
    }
Working...