CodeItBetter Programming Another VB Programming Blog

How to remove illegal characters from file name

Posted on January 4, 2009
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
'String Manipulation - How to remove illegal characters from file name
'To remove illegal characters
Public Function MakeLegalFileName5(ByVal strFileName As String) As String
    'Illegal characters are:
    '"\",  "/", ":" , "*", "?", "<",">", "|",Chrw$(34)
    strFileName = Replace(strFileName, "\", "")
    strFileName = Replace(strFileName, "/", "")
    strFileName = Replace(strFileName, ":", "")
    strFileName = Replace(strFileName, "*", "")
    strFileName = Replace(strFileName, "?", "")
    strFileName = Replace(strFileName, "<", "")
    strFileName = Replace(strFileName, ">", "")
    strFileName = Replace(strFileName, "|", "")
    strFileName = Replace(strFileName, ChrW$(34), "")
    MakeLegalFileName5 = strFileName
End Function
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


 

No trackbacks yet.