HasValidFileNameChars error for UNC files

For me, the HasValidFileNameChars function (in Delphi XE7) returns false for UNC files:

B:= IOUtils.TPath.HasValidFileNameChars('\\ETA-PC\tests\test.ini', FALSE)          
B is false now

      

This means that if you try to check the file name I show in my test (yes, the file is real, and since you can see its correct name) HasValidFileNameChars will fail. HasValidPathChars works!
This is normal?

- Edit:

On the help page, the first parameter is named "path". This led me to believe that the function would accept full paths.

Quote:

 Name        Meaning         
 Path        The verified file name string.

      

+3


source to share


2 answers


Use HasValidPathChars instead of HasValidFileNameChars , The file name cannot contain a backslash.



+5


source


The function behaves correctly because it is \

not a valid character for a filename. This is a path separator.

This is where file names and paths differ. Using your example, \\ETA-PC\tests\test.ini

is the path but the filename test.ini

.



I suspect what you are looking for HasValidPathChars

.

+3


source







All Articles