I figured this has to be in the RTL somewhere, but I looked and I can't find it.
function IsValidFilename(filename: string): boolean;
//returns True if it would be possible to create or open a file with
//this name, without modifying the current directory structure
In other words, it has to point to an existing folder on a valid local or network drive, and not contain any invalid characters. Do we have anything like that? (Bonus points if it checks the current user's access rights to be sure you can get at the folder in question.)
The File Validation Agent solution determines whether the files associated with documents in a workspace are missing. It searches for those files on a file server. It sets the value of a Yes/No field called the missing files indicator field. The value in this field indicates whether the files were found.
Supported characters for a file name are letters, numbers, spaces, and ( ) _ - , . *Please note file names should be limited to 100 characters. Characters that are NOT supported include, but are not limited to: @ $ % & \ / : * ?
So, this question is a bit old but in case you're looking: With XE and newer you can use the TPath
class in System.IOUtils
.
Result := TPath.HasValidFileNameChars(AFileName, UseWildcards);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With