ciao,
sono da poco entrato nel mondo vb.net ..
ho una form con un pulsante, cliccandoci su si dovrebbe aprire la finestra di dialogo per selezionare un txt, e in un msgbox indicarmi il contenuto..
ora, sono riuscito a fare le due cose separate:
aprire finestra dialogo:
openFileDialog1.InitialDirectory = "c:\"
openFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*"
openFileDialog1.FilterIndex = 2
openFileDialog1.RestoreDirectory = True
If openFileDialog1.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
Try
myStream = openFileDialog1.OpenFile()
If (myStream IsNot Nothing) Then
' Insert code to read the stream here.
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
leggere un file e scriverlo in una listbox:
If File.Exists("c:\test.txt") Then
'file_name = "c:\test.txt"
TextBox1.Text = file_name
appo = sr.ReadLine()
'MsgBox(appo)
ListBox1.Items.Clear()
ListBox1.Items.Add(appo)
End If
come unisco le due cose????
grazie

Rispondi quotando
