How do you change directories using FtpWebRequest (.NET)?

前端 未结 3 2068
陌清茗
陌清茗 2020-12-06 12:53

Can someone tell me how to change directories using FtpWebRequest? This seems like it should be an easy thing to do, but I\'m not seeing it.

EDIT

3条回答
  •  清歌不尽
    2020-12-06 12:59

    You have to close the current connection:

    request.Close();
    

    And open a new one with an other uri:

    uri = "ftp://example.com/%2F/directory" //Go to a forward directory (cd directory)
    uri = "ftp://example.com/%2E%2E" //Go to the previously directory (cd ../)
    
    FtpWebRequest request = (FtpWebRequest)WebRequest.Create(uri);
    

提交回复
热议问题