none
Too Many Back Slashes RRS feed

  • Question

  • If I do the below code snippet I end up with too many back slashes in the file names.  Looks like a version 0.5 bug.  At least it is different than what version 0.4 used to do.

    filearr=file.GetFiles("c:\")
    TextWindow.WriteLine(filearr)
    TextWindow.Pause()

    It would show like the following for each file:

    c:\\Stats.dat

    JR

    PS  This appears to only show with what is printed in the textwindow. 
    Wednesday, June 17, 2009 10:32 PM
    Answerer

Answers

  • File.GetFiles returns an array.  What you're seeing is an internal representation of the Array.  You need to iterate over the array to find the files you want. 

    For example:

    filearr = File.GetFiles("c:\")
    TextWindow.WriteLine(filearr[1])

    or,

    For i = 1 to Array.GetItemCount(filearr)
      TextWindow.WriteLine(filearr[i])
    endFor
    Wednesday, June 17, 2009 10:39 PM
    Moderator

All replies

  • File.GetFiles returns an array.  What you're seeing is an internal representation of the Array.  You need to iterate over the array to find the files you want. 

    For example:

    filearr = File.GetFiles("c:\")
    TextWindow.WriteLine(filearr[1])

    or,

    For i = 1 to Array.GetItemCount(filearr)
      TextWindow.WriteLine(filearr[i])
    endFor
    Wednesday, June 17, 2009 10:39 PM
    Moderator
  • I think it may be better to not let programmers see the 'insides' of an array.  I guess this would be at the expense of not being able to save raw array's to a file in one bang, but that's not so bad really.

    Otherwise this'll keep coming up.
    Thursday, June 18, 2009 1:12 AM