From: Wolfgang Enzinger on 14 Mar 2010 06:21 On Fri, 12 Mar 2010 09:13:25 -0600, DanS wrote: >I use this function in a personal project. It could be >finished w/some error handling..... > >(The case line is wrapped.) > >Public Function isValidFileName(fileName As String) As Boolean > >Dim x As Long > >isValidFileName = True >For x = 1 To Len(fileName) > Select Case Mid$(fileName, x, 1) > Case "/", "\", ":", "*", "?", "<", ">", "|", Chr > $(34), Chr$(9), Chr$(10), vbNullChar > isValidFileName = False > Exit Function > End Select >Next > >End Function Quite similar to what I use. Additionally, a file name is invalid when * it is "CLOCK$", "AUX", "CON", "NUL", "PRN", "COM1" To "COM9", "LPT1" To "LPT9" * it consists of nothing else but dots
From: DanS on 14 Mar 2010 09:08 Wolfgang Enzinger <usenet200812(a)temporaryforwarding.com> wrote in news:jtdpp5tf07d6s2pk2dak1pi0f75quhbvi9(a)4ax.com: > On Fri, 12 Mar 2010 09:13:25 -0600, DanS wrote: > >>I use this function in a personal project. It could be >>finished w/some error handling..... >> >>(The case line is wrapped.) >> >>Public Function isValidFileName(fileName As String) As >>Boolean >> >>Dim x As Long >> >>isValidFileName = True >>For x = 1 To Len(fileName) >> Select Case Mid$(fileName, x, 1) >> Case "/", "\", ":", "*", "?", "<", ">", "|", >> Chr >> $(34), Chr$(9), Chr$(10), >> vbNullChar >> isValidFileName = False >> Exit Function >> End Select >>Next >> >>End Function > > Quite similar to what I use. Additionally, a file name is > invalid when > > * it is "CLOCK$", "AUX", "CON", "NUL", "PRN", "COM1" To > "COM9", "LPT1" To "LPT9" > > * it consists of nothing else but dots I didn't think of those..... It's been a long time since I did any of those operations.... Probably back in the very early 90s when using an HP Plotter and dumping an HPGL file to it. I wonder if anyone under the age of 30 even knows about specifying hardware destinations like that.......copy file.prn LPT1
From: JPB on 14 Mar 2010 11:01 And for NTFS drives, the following filenames are invalid for the *root* directory of the drive: $MFT, $MFTMirr, $LogFile, $Volume, $AttrDef, $Bitmap, $Boot, $BadClus, $Secure, $Upcase, and $Extend They seem to be valid outside of the root directory though. On Mar 14, 6:21 am, Wolfgang Enzinger <usenet200...(a)temporaryforwarding.com> wrote: > On Fri, 12 Mar 2010 09:13:25 -0600, DanS wrote: > >I use this function in a personal project. It could be > >finished w/some error handling..... > > >(The case line is wrapped.) > > >Public Function isValidFileName(fileName As String) As Boolean > > >Dim x As Long > > >isValidFileName = True > >For x = 1 To Len(fileName) > > Select Case Mid$(fileName, x, 1) > > Case "/", "\", ":", "*", "?", "<", ">", "|", Chr > > $(34), Chr$(9), Chr$(10), vbNullChar > > isValidFileName = False > > Exit Function > > End Select > >Next > > >End Function > > Quite similar to what I use. Additionally, a file name is invalid when > > * it is "CLOCK$", "AUX", "CON", "NUL", "PRN", "COM1" To "COM9", "LPT1" > To "LPT9" > > * it consists of nothing else but dots
From: JPB on 14 Mar 2010 11:04 And sorry for top-posting in my previous reply!
From: Wolfgang Enzinger on 14 Mar 2010 14:30
On Sun, 14 Mar 2010 08:01:14 -0700 (PDT), JPB wrote: >And for NTFS drives, the following filenames are invalid for the >*root* directory of the drive: > >$MFT, $MFTMirr, $LogFile, $Volume, $AttrDef, $Bitmap, $Boot, $BadClus, >$Secure, $Upcase, and $Extend > >They seem to be valid outside of the root directory though. Interesting finding, thanks. Never noticed those before. |