. Topicala Page Index Token

A Journal about the experiences I have developing little applications in C#, Perl, Html and Javascript and talking about things new things that I use. Always Geeky; Always Nerdy; Always poor Grammer!

I am a Software Analyst Developer working in Southport, England but living in Liverpool. I develop mainly in C# and ASP.Net. I have been developing comercial software for several years now. I maintain this site (hosted at SwitchMedia UK) as a way of exploring new technologies (such as AJAX) and just generally talking about techie geek issues. This site is developed through a host of Perl scripts and a liberal use of Javascript. I enjoy experimenting with new technologies and anything that I make I host here.

Quick Search

Web www.kinlan.co.uk

Friday, November 18, 2005

Google Search Query: how to know if a certain file is a folder in c#

Someone visited my site from google using the query: how to know if a certain file is a folder in c#

I thought I would answer it because it is not on my site and I really belive that if people come to my site they should have a chance to find what they are looking for.

Basically, there is a class called "File" in the System.IO namespace, this class exposes a lot of static methods, one of them is GetAttributes [File.GetAttributes(string pathName)]. This static method returns a FileAttributes Enumeration which in turn has a property "Directory". If the file specified by the PathName parameter is a Directory then the enumeration can be logically tested by performing the following boolean statement.

((File.GetAttributes(path) & FileAttributes.Directory) == FileAttributes.Directory

This statement will logically [not conditionally] AND the enumeration with the Directory Attribute on the enumeration, this will leave the enumeration with only the Directory Flag set if it is already set, which can then be tested against the attribute directly. The enumeration is probably specified with the Flags attribute.

Technorati Tags
[feed], [feed], [feed], [feed], [feed], [feed], [feed], [feed]

Related Wikipedia Documents
, , , , , , ,

My Related Documents
,

Related Amazon Books
Build Your Own ASP.NET Website Using C# & VB.NET: /, C# & VB.NET Conversion Pocket Reference: /, Programming C#: /, ASP.NET Unleashed (Unleashed S.): /, ASP.NET 2.0 A Developer's Notebook: /, Windows Forms Programming in C#: /

Comments: [Add New]