F Franky Dec 11, 2006 #1 Given the path to a file how can I tell if it is a folder or a non-folder file? Thanks
R RobinS Dec 11, 2006 #2 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.
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.
M Michael C Dec 11, 2006 #3 Franky said: Given the path to a file how can I tell if it is a folder or a non-folder file? Click to expand... Folder.Exists or File.Exists I think.
Franky said: Given the path to a file how can I tell if it is a folder or a non-folder file? Click to expand... Folder.Exists or File.Exists I think.
C C-Services Holland b.v. Dec 11, 2006 #4 Franky said: Given the path to a file how can I tell if it is a folder or a non-folder file? Thanks Click to expand... 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.
Franky said: Given the path to a file how can I tell if it is a folder or a non-folder file? Thanks Click to expand... 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.