Click to See Complete Forum and Search --> : checking FolderName


Jeong
August 14th, 2001, 09:18 PM
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.

Iouri
August 15th, 2001, 07:14 AM
' 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
iouri@hotsheet.com

Sharathms
August 15th, 2001, 07:34 AM
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

Sharathms
August 15th, 2001, 07:39 AM
If you are using this function, sorry, i fogot to set the return value for the function.
cheers,
Sharath