Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jan 19th, 2005, 8:31 PM   #1
n3o_X
Newbie
 
Join Date: Jan 2005
Posts: 29
Rep Power: 0 n3o_X is on a distinguished road
Finding directories

I was wondering if I can use wildcards in a path. I'm trying to find out if a certain directory exists in C:\Program Files..

I know I can use if (!Directory.Exists(C:\Program Files\Test Prog)

But can is there a way to find the directory without being exact? Like

if (Directory.Exists(C:\Program Files\Tes*) to see if any folder with test exists?

Thanks.. hope i was clear enough
n3o_X is offline   Reply With Quote
Old Jan 19th, 2005, 9:03 PM   #2
n3o_X
Newbie
 
Join Date: Jan 2005
Posts: 29
Rep Power: 0 n3o_X is on a distinguished road
Hmm, Never mind, I found a better solution, but I have a question about File.Delete...

Can I Use something like this:

File.Delete(@"C:\Program Files\test.exe");

Or do i not need the @?
n3o_X is offline   Reply With Quote
Old Jan 19th, 2005, 9:46 PM   #3
thechristelegacy
Expert Programmer
 
thechristelegacy's Avatar
 
Join Date: Jul 2004
Location: Somerset, Pa
Posts: 708
Rep Power: 5 thechristelegacy is on a distinguished road
Send a message via AIM to thechristelegacy Send a message via MSN to thechristelegacy
Hmm, I'm not sure, but I do know a way you can find out, just make test.txt, and try deleting it.
thechristelegacy is offline   Reply With Quote
Old Feb 6th, 2005, 3:21 AM   #4
Enselic
Newbie
 
Enselic's Avatar
 
Join Date: Feb 2005
Location: Bankeryd, Sweden
Posts: 2
Rep Power: 0 Enselic is on a distinguished road
Send a message via MSN to Enselic
Yes, you can use File.Delete. You can read more about it at MSDN: File.Delete Method (.NET Framework).

The @ as a prefix for a string is often used with path-strings. Instead of using the esapce sequence for a backslash ('\\'), you can use @ to disable '\' as a escape char, so instead of specifying the string "C:\\Programs\\ChromeCode\\LineCounter\\Data\\" you can write @"C:\Programs\ChromeCode\LineCounter\Data\". This increases the readability.
Enselic is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 9:53 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC