Results 1 to 6 of 6

Thread: [RESOLVED] Illegal characters in path.

  1. #1

    Thread Starter
    Addicted Member Alexandru_mbm's Avatar
    Join Date
    Jul 2007
    Location
    VBForums.com
    Posts
    157

    Resolved [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()
    I'm still learning VB.NET
    Sorry for my bad english
    Thanks for your help

  2. #2
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,290

    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.

  3. #3

    Thread Starter
    Addicted Member Alexandru_mbm's Avatar
    Join Date
    Jul 2007
    Location
    VBForums.com
    Posts
    157

    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
    ----------------
    I'm still learning VB.NET
    Sorry for my bad english
    Thanks for your help

  4. #4
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    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.
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

  5. #5
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,290

    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)

  6. #6

    Thread Starter
    Addicted Member Alexandru_mbm's Avatar
    Join Date
    Jul 2007
    Location
    VBForums.com
    Posts
    157

    Re: Illegal characters in path.

    Thanks alot!
    It work's great!
    I'm still learning VB.NET
    Sorry for my bad english
    Thanks for your help

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width