CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2001
    Location
    Los Angeles, CA, United States
    Posts
    47

    checking FolderName

    How can I check folder name whether it is fit or not?
    For example, "MyFolder" is suitable for the folder name but "M? Folder" is not suitable.
    Do I have to check manually?
    Or is there some VB(or Win32API) function that can check it?
    Could anyone who know it let me know?
    Thank you

    I'm a senior programmer.
    Working at CamSight, Dental imaging solutions industry.

  2. #2
    Join Date
    May 2000
    Location
    New York, NY, USA
    Posts
    2,878

    Re: checking FolderName

    ' Display the names in C:\ that represent directories.
    MyPath = "c:\" ' Set the path.
    MyName = Dir(MyPath, vbDirectory) ' Retrieve the first entry.
    Do While MyName <> "" ' Start the loop.
    ' Ignore the current directory and the encompassing directory.
    If MyName <> "." And MyName <> ".." Then
    ' Use bitwise comparison to make sure MyName is a directory.
    If (GetAttr(MyPath & MyName) And vbDirectory) = vbDirectory Then
    if MyName = "MyFolder" then
    'do something
    else
    'msgbox "Wrong folder"
    end if
    End If ' it represents a directory.
    End If
    MyName = Dir ' Get next entry.
    Loop


    Iouri Boutchkine
    [email protected]
    Iouri Boutchkine
    [email protected]

  3. #3
    Join Date
    Aug 1999
    Location
    Bangalore, INDIA
    Posts
    70

    Re: checking FolderName

    Hi
    i am not sure about the question. is this what you need? i use this and it has been pretty useful for me (this validates only the file name, not filename with folder)
    Sharath

    private Function CheckForInvalidChars(byval strFileName as string) as Boolean
    Const c_mstrInvalidCharecters as string = "\/:*<>|?"
    blnLocalReturnValue = true
    blnValue = false
    intPos = 1
    Do While (blnValue = false)
    strChar = mid(c_mstrInvalidCharecters, intPos, 1)
    If strChar <> "" then
    If InStr(1, strFileName, strChar, vbTextCompare) > 0 then
    blnValue = true
    blnLocalReturnValue = false
    End If
    End If
    If intPos > len(c_mstrInvalidCharecters) then blnValue = true
    intPos = intPos + 1
    Loop
    End Function






  4. #4
    Join Date
    Aug 1999
    Location
    Bangalore, INDIA
    Posts
    70

    Re: checking FolderName

    If you are using this function, sorry, i fogot to set the return value for the function.
    cheers,
    Sharath


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

Featured