[RESOLVED] Illegal characters in path.
I dont know where is the problem...
How can i fix this error "Illegal characters in path." ?
The code i use is...
Code:
Dim reader As New StreamReader(My.Settings.masuratori_preluare_date)
Do While reader.Peek <> -1
Dim fileName As String
fileName = IO.Path.GetFileNameWithoutExtension(reader.ReadLine)
Me.ListBox1.Items.Add(fileName)
Loop
reader.Close()
Re: Illegal characters in path.
1. Check if [My.Settings.masuratori_preluare_date] returns a valid file path.
2. Open that file and look thru each line to see it's a valid file path.
Re: Illegal characters in path.
File path is: C:\tempest02.TXT
an the file contents is:
*** TELEGAN ***
TEMPEST 100 V3.3
DATE 10-03-08
TIME 12:57:59
NATURAL GAS
AMBIENT C 18
INTA .... ABSENT
STACK C 17
NETT C -1
O2 % .... 20.9
XAIR O2 > 20%
CO ppm ..... 0
CO2 % ..... 0.0
EFF ..... RANGE
DRY LOSS % 11.2
WET LOSS % 0.0
uCO LOSS % 0.0
NO ppm ..... 0
NOx ppm ..... 0
NO2 ppm ..... 0
SO2 ppm ..... 0
H2S ppm ..... 0
uHC .... ABSENT
Prs. inWG 0.00
V m/s ... 1.2
REF. %O2 ... 3.0
----------------
Re: Illegal characters in path.
The lines in that file are not filenames/paths to files, so why are you calling IO.Path.GetFileNameWithoutExtension() on them? Thats whats causing the error.
Re: Illegal characters in path.
OK... so the lines in your file are not file paths at all... You have to read them as is and add to your listbox
Code:
Dim reader As New StreamReader(My.Settings.masuratori_preluare_date)
Do While reader.Peek <> -1
Me.ListBox1.Items.Add(reader.ReadLine)
Loop
reader.Close()
Or even shorter this way
Code:
Dim lines() As String = IO.File.ReadAllLines(My.Settings.masuratori_preluare_date)
Me.ListBox1.Items.AddRange(lines)
Re: Illegal characters in path.
Thanks alot!
It work's great!