Is there an established convention for separating Windows file names in a string?

Posted by Heinzi on Programmers See other posts from Programmers or by Heinzi
Published on 2012-10-24T07:48:12Z Indexed on 2012/10/24 11:16 UTC
Read the original article Hit count: 458

Filed under:
|
|

I have a function which needs to output a string containing a list of file paths. I can choose the separation character but I cannot change the data type (e.g. I cannot return a List<string> or something like that).

Wanting to use some well-established convention, my first intuition was to use the semicolon, similar to what Windows's PATH and Java's CLASSPATH (on Windows) environment variables do:

C:\somedir\somefile.txt;C:\someotherdir\someotherfile.txt

However, I was surprised to notice that ; is a valid character in an NTFS file name.

So, is the established best practice to

  • just ignore this fact (i.e. "no sane person should use ; in a file name and if they do, it's their own fault") or
  • is there some other established character for separating Windows paths or files? (The pipe (|) might be a good choice, but I have not seen it used anywhere yet for this purpose.)

© Programmers or respective owner

Related posts about Windows

Related posts about file-systems