OrElse
OrElse

Reputation: 9989

Creating directory in FTP

i am using the following piece of code to create a directory. The problem is that i do not get an error, but i do not also find the directory i justt created.

So, what am i doing wrong here? Should i take a break?

 Public Function CreateDirectory(ByVal Dir As String) As Boolean
        Dim myftprequest As Net.FtpWebRequest = CType(FtpWebRequest.Create(FTPSite + Dir), FtpWebRequest)
        myftprequest.Credentials = New NetworkCredential(UserName, Password)
        myftprequest.Method = WebRequestMethods.Ftp.MakeDirectory
        Return True
    End Function

Upvotes: 2

Views: 4335

Answers (1)

McAden
McAden

Reputation: 13970

I'm not really a VB person so this syntax might be a bit off but I believe you're missing something along the lines of:

Dim myFtpResponse As Net.FtpWebResponse = CType(request.GetResponse(), FtpWebResponse)

Otherwise you're never actually DOING anything with the request except for creating it.

Upvotes: 4

Related Questions