|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
how can I tell if it is a folder or a non-folder fileGiven the path to a file how can I tell if it is a folder or a non-folder
file? Thanks 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. ---------------------------------------- Show quoteHide quote " Franky" <frankieNOSPAM@a-znet.com> wrote in message news:%23lsdEUMHHHA.3668@TK2MSFTNGP02.phx.gbl... > Given the path to a file how can I tell if it is a folder or a > non-folder file? > > > > Thanks > > " Franky" <frankieNOSPAM@a-znet.com> wrote in message Folder.Exists or File.Exists I think.news:%23lsdEUMHHHA.3668@TK2MSFTNGP02.phx.gbl... > Given the path to a file how can I tell if it is a folder or a non-folder > file? Show quoteHide quote > > > > Thanks > > Franky wrote:
> Given the path to a file how can I tell if it is a folder or a non-folder Off the top of my head...> file? > > > > Thanks > > 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. -- Rinze van Huizen C-Services Holland b.v Wow, three approaches.
thanks to all Show quoteHide quote " Franky" <frankieNOSPAM@a-znet.com> wrote in message news:%23lsdEUMHHHA.3668@TK2MSFTNGP02.phx.gbl... > Given the path to a file how can I tell if it is a folder or a non-folder > file? > > > > Thanks > >
Computer Name - Best way to obtain this VB.Net
Settings in VB.NET/WinForms How to Add *AND* Process Checkbox Column in a DataGridView? WebBrowser BeforeNavigate2 - What is pDisp? How to create an IDE? Creating A Movie Player? A Simple SQL Result displayed into a TextBox Keeping Code Snippets? Placeholder Control Shell( ) inconsistency with actual windows interfac |
|||||||||||||||||||||||