2 Replies - 226 Views - Last Post: 30 June 2012 - 07:24 AM Rate Topic: ***** 1 Votes

#1 Bluezap  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 212
  • Joined: 19-January 12

Create a Directory in ftp Sever

Posted 30 June 2012 - 12:09 AM

Hey,
I created a program to upload any file on my ftp server. Is there any way i can modify this code to create a new directory (for example a directory named "images") and then upload the file to that directory?


Public Class ftpuploader1

    Private Sub UploadButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UploadButton.Click
        Try
            My.Computer.Network.UploadFile(TextBox3.Text, ftp.Text + ftplink.Text + "/" + Label5.Text, TextBox1.Text, TextBox2.Text, True, 500)
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try

        TextBox4.Text = "http://" + link.Text + "/" + Label5.Text

    End Sub

    Private Sub BrowseFile_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BrowseFile.Click

        OpenFileDialog1.ShowDialog()
        OpenFileDialog1.Title = "Chose a File"
        TextBox3.Text = OpenFileDialog1.FileName
        Label5.Text = OpenFileDialog1.SafeFileName
    End Sub

End Class



Basicaly i want to know how i could create a new directory on the ftp server from this program itself and den upload the file to the directory that i created

Please help! Thanks

Is This A Good Question/Topic? 0
  • +

Replies To: Create a Directory in ftp Sever

#2 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 4963
  • View blog
  • Posts: 10,558
  • Joined: 02-June 10

Re: Create a Directory in ftp Sever

Posted 30 June 2012 - 07:13 AM

Please stop building your paths like that.
System.IO.Path.Combine() was designed specifically for this purpose and will compensate for missing or extra divider characters (/)


You want to force the server to create a directory, from your client that is sending the file?

I'm reasonably certain you would have to first issue the commands to create directory then set that as your path. Just like if you moved a file on your local PC programmatically: You can't just specify a path that doesn't yet exist and expect the OS to make all the intermediate directories for you.
Basic FTP Commands
Was This Post Helpful? 0
  • +
  • -

#3 trevster344  Icon User is offline

  • The Peasant
  • member icon

Reputation: 215
  • View blog
  • Posts: 1,408
  • Joined: 16-March 11

Re: Create a Directory in ftp Sever

Posted 30 June 2012 - 07:24 AM

I suggest using the FTP web request objects for ftp work. Much simpler, and was intended for such use.

FTP Web Request

This can handle sending ftp commands and such.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1