473,414 Members | 1,876 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,414 software developers and data experts.

Valid directory

How do I check if the directory path is valid and exists ?

eg.
\\myserver\temp\\\\\\

c:\temp\\doc\\\\\\root1

Aug 25 '06 #1
6 6380

Alan T wrote:
How do I check if the directory path is valid and exists ?

eg.
\\myserver\temp\\\\\\

c:\temp\\doc\\\\\\root1


System.IO.Directory.Exists(@"c:\temp");
cheers

Aug 25 '06 #2
The system.io class has a directory exists method

Directory.Exists(path)

described here:

http://msdn2.microsoft.com/en-us/lib...ry.exists.aspx

As long as you have the authenticated rights to check that location it will
tell you if a path exists.

--
Regards

John Timney (MVP)
"Alan T" <al*************@yahoo.com.auwrote in message
news:ue**************@TK2MSFTNGP03.phx.gbl...
How do I check if the directory path is valid and exists ?

eg.
\\myserver\temp\\\\\\

c:\temp\\doc\\\\\\root1

Aug 25 '06 #3
I just wonder
c:\temp\\doc\\\root1\\\

it gives me that is valid directory but I need to get rid of the extra '\'s
The system.io class has a directory exists method

Directory.Exists(path)

described here:

http://msdn2.microsoft.com/en-us/lib...ry.exists.aspx

As long as you have the authenticated rights to check that location it
will tell you if a path exists.
>How do I check if the directory path is valid and exists ?

eg.
\\myserver\temp\\\\\\

c:\temp\\doc\\\\\\root1

Aug 28 '06 #4
read how to trim here

http://www.csharphelp.com/archives4/archive616.html

--
Regards

John Timney (MVP)
"Alan T" <al*************@yahoo.com.auwrote in message
news:eX**************@TK2MSFTNGP04.phx.gbl...
>I just wonder
c:\temp\\doc\\\root1\\\

it gives me that is valid directory but I need to get rid of the extra
'\'s
>The system.io class has a directory exists method

Directory.Exists(path)

described here:

http://msdn2.microsoft.com/en-us/lib...ry.exists.aspx

As long as you have the authenticated rights to check that location it
will tell you if a path exists.
>>How do I check if the directory path is valid and exists ?

eg.
\\myserver\temp\\\\\\

c:\temp\\doc\\\\\\root1


Aug 28 '06 #5
Sorry, I don't follow the article if it helps in my problem.

Is there a way to get rid of the extra '\' in the directory string?

"John Timney (MVP)" <x_****@timney.eclipse.co.ukwrote in message
news:Xb********************@eclipse.net.uk...
read how to trim here

http://www.csharphelp.com/archives4/archive616.html

--
Regards

John Timney (MVP)
"Alan T" <al*************@yahoo.com.auwrote in message
news:eX**************@TK2MSFTNGP04.phx.gbl...
>>I just wonder
c:\temp\\doc\\\root1\\\

it gives me that is valid directory but I need to get rid of the extra
'\'s
>>The system.io class has a directory exists method

Directory.Exists(path)

described here:

http://msdn2.microsoft.com/en-us/lib...ry.exists.aspx

As long as you have the authenticated rights to check that location it
will tell you if a path exists.
How do I check if the directory path is valid and exists ?

eg.
\\myserver\temp\\\\\\

c:\temp\\doc\\\\\\root1



Oct 10 '06 #6
Hi Alan,

The article explains how to do string manipulation

Basically, if you have a string of several \ where there should be only 1
you can do it like this

string s = @"c:\windows\\microsoft.net\\\framework\\\";

while (s.IndexOf(@"\\") -1)
s = s.Replace(@"\\", @"\");

The @ means treat \ as a backslash, not as an escape character


On Tue, 10 Oct 2006 05:16:45 +0200, Alan T <al*************@yahoo.com.au
wrote:
Sorry, I don't follow the article if it helps in my problem.

Is there a way to get rid of the extra '\' in the directory string?

"John Timney (MVP)" <x_****@timney.eclipse.co.ukwrote in message
news:Xb********************@eclipse.net.uk...
>read how to trim here

http://www.csharphelp.com/archives4/archive616.html

--
Regards

John Timney (MVP)
"Alan T" <al*************@yahoo.com.auwrote in message
news:eX**************@TK2MSFTNGP04.phx.gbl...
>>I just wonder
c:\temp\\doc\\\root1\\\

it gives me that is valid directory but I need to get rid of the extra
'\'s

The system.io class has a directory exists method

Directory.Exists(path)

described here:

http://msdn2.microsoft.com/en-us/lib...y.exists..aspx

As long as you have the authenticated rights to check that locationit
will tell you if a path exists.
How do I check if the directory path is valid and exists ?
>
eg.
\\myserver\temp\\\\\\
>
c:\temp\\doc\\\\\\root1





--
Happy Coding!
Morten Wennevik [C# MVP]
Oct 10 '06 #7

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

Similar topics

3
by: Mark Space | last post by:
Hi all, I followed some simple instructions to add python scrips to IIS as a cgi. The instructions were here: http://www.e-coli.net/pyiis.html Unfortunately, when I try to run a test script,...
1
by: VM | last post by:
I'm trying to debug an application in the VC dot net compiler and when I begin, I get the error: Unable to start debugging Unable to start program 'c:\myApp\PROGRAM\myApp.exe' 'G:\Program...
1
by: Jen | last post by:
Hi, I'm having an issue calling a dll from an ASP.NET page. The code that tries to instantiate a COM dll (class) is in a Class Library. I can call the code successfully from a windows...
6
by: dave | last post by:
Hello All - Is there a way to check if a file path string is valid? I.e. is there a function that takes some string, say 'c:\somedir\subdir' and returns TRUE if it is valid or FALSE if no such...
2
by: Al Reid | last post by:
What's the most efficient way to determine if an arbitrary string is a path to a valid, existing directory? Also, how can I convert the string to the same case as the original directory, assuming...
10
by: SpreadTooThin | last post by:
Hi I'm writing a python script that creates directories from user input. Sometimes the user inputs characters that aren't valid characters for a file or directory name. Here are the characters...
12
by: Pao | last post by:
Hi all For all NEW sites (virtual directories) that I create, I receive always the same error: (I translate so may be a little different) Impossible to visualize the XML page Impossible to...
0
by: Gianluca Pezzoli | last post by:
Hi, I have Windows Server 2003 x64 standard SP2 Italian, with Xeon 3.8 Ghz and 2GB RAM. On Server I found installed .net framework 1.1 and 2.0 (x64). I am developing a simple (Hello world)...
27
by: Dave | last post by:
I'm having a hard time tying to build gcc 4.3.1 on Solaris using the GNU compilers. I then decided to try to use Sun's compiler. The Sun Studio 12 compiler reports the following code, which is in...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.