简体   繁体   中英

Creation of folder on FTP fails when running on remote server

I have written code for creating folder on FTP server when a button clicks..When running my project locally, It works properly and creates a folder on FTP.. But when it running on remote server the folder is not created.. Please help .. Is there any needs to make changes on config file ? my cod is here

 public void create_folder(string userName, string password,string test_session_id)// FOR CREATING FOLDER ON FTP SERVER
{
    WebRequest request = WebRequest.Create("ftp://xxxxx/" + tb_session_id + "");
    request.Method = WebRequestMethods.Ftp.MakeDirectory;
    request.Credentials = new NetworkCredential(userName, password);

    }
}

A few questions:

Is the host (xxxxx in your example) passed to the Create method a reachable domain from your machine/network ?

What is the resp.StatusCode when you debug ?

Are any exceptions thrown ?

A similar issue: https://stackoverflow.com/a/3789350/956364

Other than that, your code looks identical to the version by Jon Skeet: How do I create a directory on ftp server using C#?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM