RotorTorque
Programmer
Hi all I have written an email generating app in VB 2005 that allows a user to attach a file. It works fine. The user selects the file from an openFileDialog control selects the file and then the file path is save to a string and the file name is displayed in an attachment text box.
They now have requested the ability to add multiple files. This brings up many issues:
1) I have to some how store the different attachment file paths.
2) Display the multiple file names in the attachment text box.
3) If the user desides to unattach a file I have to remove the file path from the list of attachments and also remove the file name from the attachment text box.
What woudl be the best way to handle this issue?
Here is a sample of my current code:
Thanks in advance,
RotorTorque ;-)
They now have requested the ability to add multiple files. This brings up many issues:
1) I have to some how store the different attachment file paths.
2) Display the multiple file names in the attachment text box.
3) If the user desides to unattach a file I have to remove the file path from the list of attachments and also remove the file name from the attachment text box.
What woudl be the best way to handle this issue?
Here is a sample of my current code:
Code:
Private Sub btnAttachments_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAttachments.Click
'Set the opendialog properties
With OpenFileDialog1
.InitialDirectory = "C:\"
.Filter = "Text files (*.txt)|*.txt|All files (*.*)|*.*"
.FilterIndex = 1
.Multiselect = False
.CheckFileExists = False
.RestoreDirectory = True
.Title = "Attach Files"
End With
'Show the open dialog and if the user clicks the open button load the file.
If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
Try
Dim s As String = OpenFileDialog1.FileName
Dim objFileInfo As System.IO.FileInfo
objFileInfo = My.Computer.FileSystem.GetFileInfo(s)
txtAttachments.Text = objFileInfo.Name
Dim strFilePath as string = objFileInfo.FullName
Catch ex As Exception
Throw ex
End Try
End If
End Sub
Thanks in advance,
RotorTorque ;-)