samedi 28 février 2015

Filtering Folders in Save File Dialog in Visual Basic


Vote count:

0




I am making an application in Visual Basic which creates a directory and places text files in them, but I want to view a directory in which the user wants the text files from. I have decided that using the OpenFileDialog option would work best. What filter would I use for the OpenFileDialog? Here's my code so far:


For the creation of the folder and documents:


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click My.Computer.FileSystem.CreateDirectory("C:/Organizer/" + BusinessName.Text)



Dim objWriter9 As New System.IO.StreamWriter("C:/Organizer/" + BusinessName.Text + "/" + "Address" + ".txt")
objWriter9.Write(Address.Text)
objWriter9.Close()

Dim objWriter As New System.IO.StreamWriter("C:/Organizer/" + BusinessName.Text + "/" + "BusinessName" + ".txt")
objWriter.Write(BusinessName.Text)
objWriter.Close()

Dim objWriter1 As New System.IO.StreamWriter("C:/Organizer/" + BusinessName.Text + "/" + "AssociateName" + ".txt")
objWriter1.Write(AssociateName.Text)
objWriter1.Close()

Dim objWriter2 As New System.IO.StreamWriter("C:/Organizer/" + BusinessName.Text + "/" + "PhoneNumber" + ".txt")
objWriter2.Write(PhoneNumber.Text)
objWriter2.Close()

Dim objWriter3 As New System.IO.StreamWriter("C:/Organizer/" + BusinessName.Text + "/" + "Email" + ".txt")
objWriter3.Write(Email.Text)
objWriter3.Close()

If CheckBox1.Checked Then
Dim objWriter4 As New System.IO.StreamWriter("C:/Organizer/" + BusinessName.Text + "/" + "Other" + ".txt")
objWriter4.Write(Other1.Text)
objWriter4.Close()
End If

If CheckBox5.Checked Then
Dim objWriter5 As New System.IO.StreamWriter("C:/Organizer/" + BusinessName.Text + "/" + BusinessName.Text + "Other1" + ".txt")
objWriter5.Write(Other3.Text)
objWriter5.Close()
End If

If CheckBox4.Checked Then
Dim objWriter6 As New System.IO.StreamWriter("C:/Organizer/" + BusinessName.Text + "/" + BusinessName.Text + "Other2" + ".txt")
objWriter6.Write(Other5.Text)
objWriter6.Close()
End If

If CheckBox3.Checked Then

End If
Dim objWriter7 As New System.IO.StreamWriter("C:/Organizer/" + BusinessName.Text + "/" + BusinessName.Text + "Other3" + ".txt")
objWriter7.Write(Other7.Text)
objWriter7.Close()

If CheckBox5.Checked Then
Dim objWriter8 As New System.IO.StreamWriter("C:/Organizer/" + BusinessName.Text + "/" + BusinessName.Text + "Other4" + ".txt")
objWriter8.Write(Other9.Text)
objWriter8.Close()
End If

End Sub


End Class`


And for the loading of it (so far):



` Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Button1.Hide()
Label1.Show()
Label2.Show()
Label3.Show()
Label4.Show()
Label5.Show()
Label6.Show()
Label7.Show()
Label8.Show()
Label9.Show()
Label10.Show()
Label11.Show()
Label12.Show()
Label13.Show()
Label14.Show()
Label15.Show()
Label16.Show()
Label17.Show()
OpenFileDialog1.InitialDirectory = "C:/Organizer"
OpenFileDialog1.Filter = "Folder|"
OpenFileDialog1.ShowDialog()
My.Computer.FileSystem.ReadAllText(OpenFileDialog1.FileName)`


Thanks for the help!



asked 1 min ago







Filtering Folders in Save File Dialog in Visual Basic

Aucun commentaire:

Enregistrer un commentaire