EvalFileName – Ensure that the basename of a file or directory is valid

' EvalFileName ensures that the basename of a file or directory' conforms to the Microsoft file naming guidelines (see MSDN webpage)' http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/base/' naming_a_file.asp'' Return value:'   True = Valid basename'   False = Invalid basename'' Note: Since EvalFileName checks only the basename of a file or' directory, it does not test the max filename length condition' (ANSI 255 for files, 248 for directories, including the path)' This error is however trapped by the APIMakeDirectory function'' Example:'   MsgBox EvalFileName("test.txt")'   MsgBox EvalFileName("inva:lid.txt")Private Function EvalFileName(ByVal Name As String) As Boolean                                Dim i As Long    Dim Test As String    Const BAD_FILENAME_CHARS As String = """" & "/" & "" & ":" & "|" & "<" & _        ">" & "*" & "?"        ' We need a name    If Len(Trim$(Name)) = 0 Then        Exit Function    End If        ' Test trailing space or period    Test = Right$(Name, 1)    If Test = " " Or Test = "." Then        Exit Function    End If        ' Test illegal and non-printable characters    Test = BAD_FILENAME_CHARS    For i = 0 To 31        Test = Test & Chr$(i)    Next    For i = 1 To Len(Name)        If InStr(1, Test, Mid$(Name, i, 1)) > 0 Then            Exit Function        End If    Next        ' Test possible use of reserved words    ' (CON, PRN, AUX, CLOCK$, NUL)    If LCase$(Name) = "con" Or LCase$(Name) = "prn" Or LCase$(Name) = "aux" Or _        LCase$(Name) = "clock$" Or LCase$(Name) = "nul" Then            Exit Function    End If    ' COM/LPT (1-9)    For i = 1 To 9        If LCase$(Name) = "com" & CStr(i) Or LCase$(Name) = "lpt" & CStr(i) Then            Exit Function        End If    Next        ' All tests clear, return success    EvalFileName = TrueEnd Function

Share the Post:
Share on facebook
Share on twitter
Share on linkedin

Overview

The Latest

your company's audio

4 Areas of Your Company Where Your Audio Really Matters

Your company probably relies on audio more than you realize. Whether you’re creating a spoken text message to a colleague or giving a speech, you want your audio to shine. Otherwise, you could cause avoidable friction points and potentially hurt your brand reputation. For example, let’s say you create a

chrome os developer mode

How to Turn on Chrome OS Developer Mode

Google’s Chrome OS is a popular operating system that is widely used on Chromebooks and other devices. While it is designed to be simple and user-friendly, there are times when users may want to access additional features and functionality. One way to do this is by turning on Chrome OS

homes in the real estate industry

Exploring the Latest Tech Trends Impacting the Real Estate Industry

The real estate industry is changing thanks to the newest technological advancements. These new developments — from blockchain and AI to virtual reality and 3D printing — are poised to change how we buy and sell homes. Real estate brokers, buyers, sellers, wholesale real estate professionals, fix and flippers, and beyond may