473,395 Members | 1,968 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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

Given the path to a file how can I tell if it is a folder or a non-folder
file?

Thanks
Dec 11 '06 #1
4 980
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" <fr***********@a-znet.comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
Given the path to a file how can I tell if it is a folder or a
non-folder file?

Thanks


Dec 11 '06 #2
" Franky" <fr***********@a-znet.comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
Given the path to a file how can I tell if it is a folder or a non-folder
file?
Folder.Exists or File.Exists I think.
>
Thanks


Dec 11 '06 #3
Franky wrote:
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.

--
Rinze van Huizen
C-Services Holland b.v
Dec 11 '06 #4
Wow, three approaches.
thanks to all
" Franky" <fr***********@a-znet.comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
Given the path to a file how can I tell if it is a folder or a non-folder
file?

Thanks


Dec 11 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

303
by: mike420 | last post by:
In the context of LATEX, some Pythonista asked what the big successes of Lisp were. I think there were at least three *big* successes. a. orbitz.com web site uses Lisp for algorithms, etc. b....
17
by: Mike A | last post by:
Hi, I'm hoping someone can help me with this. I have a URL for which I'd like to limit access to by time. For example,say I have a URL that I don't want accessable on Monday mornings between...
5
by: davesuemcbride | last post by:
Hi All, I built a great looking page to learn CSS, using div's for 'rows' and span's for 'columns' - nice complex layout where I could create just about anything by endlessly nesting them as...
3
by: Zeng Dinghao | last post by:
char c = 'd'; const char cc = 'd'; char* pc = "dfdfdf"; const char* pcc = "dfdfdf"; char const* cpc = "dfdf"; cout << typeid(c).name() << endl; cout << typeid(cc).name() << endl; cout <<...
10
by: Simon Elliott | last post by:
Is there a way at compile time to determine if a function has been declared? My specific reason for this is because of memicmp() and stricmp() which are declared in namespace std by some...
4
by: ±èµ¿±Õ | last post by:
Tell me why the symbol "_" use in the Library? For example, char *_itoa( int value, char *string, int radix ); But We use function "itoa(value,string,radix) "only. I want to know the...
6
by: ashishnh33 | last post by:
cud any one tell me what is the problem in this program #include<iostream.h> #include<conio.h> #include<stdlib.h> int binarysearch(void) int linearsearch(void) class search { private:...
7
by: martinfrompi | last post by:
I have a container of XmlNodes. Some of them have been removed from the document, some haven't. Is there an easy way to tell which are which? I suppose bool IsPartOfTree(XmlNode node) {...
22
by: =?ISO-8859-1?Q?Tom=E1s_=D3_h=C9ilidhe?= | last post by:
I already understand how program compilation works (i.e. the preprocessor produces individual translation units which get compiled separately, and then the linker links the object files together),...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.