|
-
November 22nd, 1999, 05:22 PM
#1
Validate filename
Does anyone knows how to know if a string is a valid Windows long file name?
In other words, I need to know which ascii values out of the the (255) ASCII code characers are valid in a windows long filename.
-
November 23rd, 1999, 12:08 PM
#2
Re: Validate filename
Assuming you do not need to add the extra complication of the path along with the filename, you can test out each character to see if it is NOT a valid character. This is easier than seeing if it IS valid. VB has a list of ASCII codes built into the help file - if you search for character codes or something like that you should find it. File names cannot include any of the following characters: forward slash (/), backslash (\), greater than sign (> , less than sign (< , asterisk (*), period (.), question mark (?), quotation mark ("), pipe symbol (|), colon ( , or semicolon ( . Just for your convienience - here is a list of ASCII codes which are NOT allowed in Windows long filenames...I think I've got them all right:
34 Quotation mark
42 Asterisk
46 Period
47 Slash
58 Colon
59 Semicolon
60,62 Greater than, less than symbols
63 Question mark
92 Slash
124 Pipe
After checking the characters in the filename, you can then check that it does not exceed 255 chars:
if len(Variable) >= 255 then
'invalid
else
'valid
end if
This is just one way to do it. Another way would be to try and save the file to disk first, but set up an error trap and assign the function a return variable. By seeing if the returned value is success/failure, you can determine whether or not the file name is valid.
Regards,
psiclone.
-
November 28th, 1999, 12:38 PM
#3
Re: Validate filename
psiclone,
Hi, just wondering how to test each character in a name or string to see if value is valid or not.
something like this:
string = "j-manning"
I want to be able to look at each character in this string and determine if it fits my criteria for being valid. Valid codes are 48-57, 65-90, 97 -122, 45, 46, 95.
Any help or direction would be appreciated greatly. Thx Harold
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|