I have written code which uploads a file to a server (this will eventually have to change to by FTP) it currently works correctly.
However I have since tried to modify it to create the directory for the file if it doesnt exist. This part is causing me problems.

FileWebResponse FTPRes = (FileWebResponse)FTPReq.GetResponse();

when the code hits the above line I get a file not found error? Its confusing as I dont expect it to find it I want it to create the directory so I can upload to it?

Code:
  private static void Upload(string ftpServer, string userName, string password, string filename, string directory)
        {
           
            if (!WebRequestMethods.Ftp.ListDirectoryDetails.Contains(directory))
            {
                FileWebRequest FTPReq = FileWebRequest.Create(directory) as FileWebRequest;
                FTPReq.Credentials = new NetworkCredential("", "");

                FTPReq.Method = WebRequestMethods.Ftp.MakeDirectory;
                FileWebResponse FTPRes = (FileWebResponse)FTPReq.GetResponse();
            }
            using (System.Net.WebClient client = new System.Net.WebClient())
            {
               

                client.Credentials = new System.Net.NetworkCredential(userName, password);
                client.UploadFile(ftpServer + "/" + new FileInfo(filename).Name, "STOR", filename);
            }
        }