K
Kai Apel
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(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmdDialog.Click
Dim myStream As Stream = Nothing
Dim ofd As New OpenFileDialog()
With ofd
.InitialDirectory = "C:\" 'Preselection Filelocation
.Title = "Selected Files" 'Title
.Filter = "MP3-Format (*.mp3)|*.mp3|WAVE-Format (*.wav)|
*.wav" 'Filefilter
.FilterIndex = 2 'Preselectet Extension
.RestoreDirectory = False
.Multiselect = True 'to select multiple files
End With
If ofd.ShowDialog() = System.Windows.Forms.DialogResult.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.Critical +
MsgBoxStyle.OkOnly)
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(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmdDialog.Click
Dim myStream As Stream = Nothing
Dim ofd As New OpenFileDialog()
With ofd
.InitialDirectory = "C:\" 'Preselection Filelocation
.Title = "Selected Files" 'Title
.Filter = "MP3-Format (*.mp3)|*.mp3|WAVE-Format (*.wav)|
*.wav" 'Filefilter
.FilterIndex = 2 'Preselectet Extension
.RestoreDirectory = False
.Multiselect = True 'to select multiple files
End With
If ofd.ShowDialog() = System.Windows.Forms.DialogResult.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.Critical +
MsgBoxStyle.OkOnly)
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