Dear Newsgroup,
My name is Kai from Germany and I`m trying to learn VB.Net. My first
Project is a simple Form with a button, witch is starting the
filedialog for multiselect file. All thats fine. Now I want
automaticly upload this selected file via FTP.
I'm using Windows.Forms:
My Code:
Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles cmdDialog.Click
Dim myStream As Stream = Nothing
Dim ofd As New OpenFileDialog( )
With ofd
.InitialDirecto ry = "C:\" 'Preselection Filelocation
.Title = "Selected Files" 'Title
.Filter = "MP3-Format (*.mp3)|*.mp3|W AVE-Format (*.wav)|
*.wav" 'Filefilter
.FilterIndex = 2 'Preselectet Extension
.RestoreDirecto ry = False
.Multiselect = True 'to select multiple files
End With
If ofd.ShowDialog( ) = System.Windows. Forms.DialogRes ult.OK
Then
Try
myStream = ofd.OpenFile()
If (myStream IsNot Nothing) Then
'Here I need to place the Code for Uploading the selected files to a
webserver via ftp
Else
MsgBox("Nothing selected!", MsgBoxStyle.Cri tical +
MsgBoxStyle.OkO nly)
Exit Sub
End If
Catch Ex As Exception
MessageBox.Show ("Cannot read file from disk. Original
error: " & Ex.Message)
Finally
' Check this again, since we need to make sure we
didn't throw an exception on open.
If (myStream IsNot Nothing) Then
myStream.Close( )
End If
End Try
End If
My name is Kai from Germany and I`m trying to learn VB.Net. My first
Project is a simple Form with a button, witch is starting the
filedialog for multiselect file. All thats fine. Now I want
automaticly upload this selected file via FTP.
I'm using Windows.Forms:
My Code:
Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles cmdDialog.Click
Dim myStream As Stream = Nothing
Dim ofd As New OpenFileDialog( )
With ofd
.InitialDirecto ry = "C:\" 'Preselection Filelocation
.Title = "Selected Files" 'Title
.Filter = "MP3-Format (*.mp3)|*.mp3|W AVE-Format (*.wav)|
*.wav" 'Filefilter
.FilterIndex = 2 'Preselectet Extension
.RestoreDirecto ry = False
.Multiselect = True 'to select multiple files
End With
If ofd.ShowDialog( ) = System.Windows. Forms.DialogRes ult.OK
Then
Try
myStream = ofd.OpenFile()
If (myStream IsNot Nothing) Then
'Here I need to place the Code for Uploading the selected files to a
webserver via ftp
Else
MsgBox("Nothing selected!", MsgBoxStyle.Cri tical +
MsgBoxStyle.OkO nly)
Exit Sub
End If
Catch Ex As Exception
MessageBox.Show ("Cannot read file from disk. Original
error: " & Ex.Message)
Finally
' Check this again, since we need to make sure we
didn't throw an exception on open.
If (myStream IsNot Nothing) Then
myStream.Close( )
End If
End Try
End If
Comment