|
-
Jan 17th, 2007, 04:59 PM
#1
Thread Starter
Member
help with filecheck program
This is my question:
Write a program with a text box, and button, and list box. The user is to place a pathname in the text box and click the button. The program should first check that the file exists, displaying a message box if it doesn’t. If it does, the program should read the file as a text, with one string per line, and place each string as a new item in the list box.
Here is the code I have so far,when I run it i think it gives the error message correctly, but it gives me an error and then doesn't put the file names into the list. could someone help me out with this?? What am I doing wrong?:
VB Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim sFileToCheck As String = TextBox.Text
Dim sFileList() As String
If File.Exists(sFileToCheck) Then
sFileList = Directory.GetFiles(TextBox.Text)
ListBox1.Items.AddRange(sFileList)
Else
MessageBox.Show("The file does not exist")
End If
End Sub
End Class
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|