P
Pascal
hello
i would like to populate a listbox with words from a list (using
openfiledialog) this list is made with one word per line like this :
manger
finir
mourir
courir
etc...
to open the file :
i tried this with fileopen until i save because a message comes telling me
than another process already use this file . here is the code :
###################################################
'Dim i As Short
'FileOpen(1, My.Application.Info.DirectoryPath & "\" & "a.txt",
OpenMode.Output)
'For i = 0 To lstInputWord.Items.Count - 1
'LaListe.SelectedIndex = i
'PrintLine(1, LaListe.Text)
'Next
'FileClose(1)
############################################"
so i changed and try with streamreader this code :
If .ShowDialog = Windows.Forms.DialogResult.OK Then
Try
Dim fileReader As System.IO.StreamReader
fileReader =
My.Computer.FileSystem.OpenTextFileReader(.FileName,
System.Text.Encoding.Default)
Dim stringReader As String = ""
lstInputWord.Items.Clear()
While Not fileReader.EndOfStream
stringReader = fileReader.ReadLine()
lstInputWord.Items.Add(stringReader)
End While
fileReader.Close()
Catch fileException As Exception
Throw fileException
End Try
##########################################
it seems to work fine like this but i am not able to change this code :
####################################################"
save and close the file :
'Dim i As Short
'FileOpen(1, My.Application.Info.DirectoryPath & "\" &
"a.txt", OpenMode.Output)
'For i = 0 To lstInputWord.Items.Count - 1
'LaListe.SelectedIndex = i
'PrintLine(1, LaListe.Text)
'Next
'FileClose(1)
###########################################
by the equivalent with streamwriter.....
so now i would like to try with stream writer but i didn't find the good
way to use it... somebody can help me
thanks
http://www.scalpa.info
i would like to populate a listbox with words from a list (using
openfiledialog) this list is made with one word per line like this :
manger
finir
mourir
courir
etc...
to open the file :
i tried this with fileopen until i save because a message comes telling me
than another process already use this file . here is the code :
###################################################
'Dim i As Short
'FileOpen(1, My.Application.Info.DirectoryPath & "\" & "a.txt",
OpenMode.Output)
'For i = 0 To lstInputWord.Items.Count - 1
'LaListe.SelectedIndex = i
'PrintLine(1, LaListe.Text)
'Next
'FileClose(1)
############################################"
so i changed and try with streamreader this code :
If .ShowDialog = Windows.Forms.DialogResult.OK Then
Try
Dim fileReader As System.IO.StreamReader
fileReader =
My.Computer.FileSystem.OpenTextFileReader(.FileName,
System.Text.Encoding.Default)
Dim stringReader As String = ""
lstInputWord.Items.Clear()
While Not fileReader.EndOfStream
stringReader = fileReader.ReadLine()
lstInputWord.Items.Add(stringReader)
End While
fileReader.Close()
Catch fileException As Exception
Throw fileException
End Try
##########################################
it seems to work fine like this but i am not able to change this code :
####################################################"
save and close the file :
'Dim i As Short
'FileOpen(1, My.Application.Info.DirectoryPath & "\" &
"a.txt", OpenMode.Output)
'For i = 0 To lstInputWord.Items.Count - 1
'LaListe.SelectedIndex = i
'PrintLine(1, LaListe.Text)
'Next
'FileClose(1)
###########################################
by the equivalent with streamwriter.....
so now i would like to try with stream writer but i didn't find the good
way to use it... somebody can help me
thanks
http://www.scalpa.info