how can I tell if it is a folder or a non-folder file

  • Thread starter Thread starter Franky
  • Start date Start date
If you have VB2005, check out the Path class.

Dim file As String = "C:\MyApp\Bin\MyApp.exe"
Path.GetDirectoryName(file) --> C:\MyApp\Bin
Path.GetFileName(file) --> MyApp.exe
Path.GetFileExtension(file) --> .exe
Path.GetFileNameWithoutExtension(file) --> MyApp

I would think if you do a GetDirectoryName on it, and it
returned the same value as was already in it, you could
assume it's a folder?

Robin S.
 
Franky said:
Given the path to a file how can I tell if it is a folder or a non-folder
file?



Thanks

Off the top of my head...

If File.GetAttributes(cFileName) And FileAttributes.Directory Then
MsgBox(cFilename + " is a directory")
Else
MsgBox(cFilename + " is a file")
EndIf

Assuming the file or directory actually exists.
 
Back
Top