Results 1 to 13 of 13

Thread: Advanced 'FileExists' (determine if file exists) [RESOLVED]

Threaded View

  1. #13
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654
    Extension can't have a space in it. If there is a space after a dot, it means the dot is part of a filename. Thus... there should be a lookup for a possible next dot.

    Now that I think about it, the most failproof way would be to check for a space, if is a space, mark the location, then look the next character until it finds a dot. Then take characters to the last position a space was found.


    VB Code:
    1. 'in a module
    2. Public Function RemoveParams(ByVal Filename As String) As String
    3.     Dim Buffer() As Byte
    4.     Dim A As Long, B As Long
    5.     Buffer = Filename
    6.     A = (UBound(Buffer) Or 1) - 1
    7.     Do While Buffer(A) = 46
    8.         If Buffer(A) = vbKeySpace Then B = A
    9.         A = A - 2
    10.         If A < 0 Then RemoveParams = Buffer: Exit Function
    11.     Loop
    12.     ReDim Preserve Buffer(B - 1)
    13.     RemoveParams = Buffer
    14. End Function
    Last edited by Merri; Sep 19th, 2004 at 05:37 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width