473,503 Members | 2,322 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Directory.CreateDirectory fails

The following code:

C# code:
Directory.CreateDirectory("D:\\somewhere\\somewher eelse\\here\\")

works, but the following does flags the error:

An unhandled exception of type 'System.NotSupportedException' occurred in
mscorlib.dll

Additional information: The given path's format is not supported.

C# code:
string _NewDir = "D:\\somewhere\\somewhereelse\\here\\";
Directory.CreateDirectory(_NewDir);
Why?
Nov 13 '06 #1
2 8660
Works fine for me in .Net 2.0.

Suggestions:
Copy and paste your code into a code editor like UltraEdit and check for non
ASCII characters.

Here's my listing:

class Program
{
static void Main(string[] args)
{
string _NewDir = "c:\\somewhere\\somewhereelse\\here\\";
try
{
Directory.CreateDirectory(_NewDir);
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
Console.ReadLine();

}
}
--
Good luck!

Shailen Sukul
Architect
(BSc MCTS, MCSD.Net MCSD MCAD)
Ashlen Consulting Service P/L
(http://www.ashlen.net.au)
"Toolsmith" wrote:
The following code:

C# code:
Directory.CreateDirectory("D:\\somewhere\\somewher eelse\\here\\")

works, but the following does flags the error:

An unhandled exception of type 'System.NotSupportedException' occurred in
mscorlib.dll

Additional information: The given path's format is not supported.

C# code:
string _NewDir = "D:\\somewhere\\somewhereelse\\here\\";
Directory.CreateDirectory(_NewDir);
Why?
Nov 13 '06 #2
Rad
On Mon, 13 Nov 2006 12:23:01 -0800, Toolsmith
<To*******@discussions.microsoft.comwrote:
>The following code:

C# code:
Directory.CreateDirectory("D:\\somewhere\\somewher eelse\\here\\")

works, but the following does flags the error:

An unhandled exception of type 'System.NotSupportedException' occurred in
mscorlib.dll

Additional information: The given path's format is not supported.

C# code:
string _NewDir = "D:\\somewhere\\somewhereelse\\here\\";
Directory.CreateDirectory(_NewDir);
Why?
Works for me too.
Nov 14 '06 #3

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

Similar topics

1
2411
by: Daniel | last post by:
If I call CreateDirectory(\\\\devDriveA\\foo\\bar\\a\\b\\c) and \\devDriveA\foo\bar already exists then sub directories a\b\c don't get created. When I use CreateDirectory on my own file system,...
1
1514
by: H.B. | last post by:
Hi, Is there a way to avoid conflicts between CreateDirectory() (from API) and Directory::CreateDirectory(). The other functions from Directory class works(Exists() as example). It seems to be...
1
2404
by: Sparky | last post by:
I want to create a directory on my web server from within code. I've tried using Request.PhysicalApplicationPath() to get the location of the application, and appended my new directory on the end...
3
2277
by: James Coleman | last post by:
Hello, The following error is appearing when attempting to create a directory using the availale system.io methods: System.IO.DirectoryNotFoundException: Could not find a part of the path...
2
2187
by: Paul Bromley | last post by:
How can I create a directory within a shared ntwork directory?? sServerName - is the Server name "\Docs" - is the shared directory "\Others" - is the directory to create. The following...
23
2395
by: **Developer** | last post by:
Is there an easy way to copies all files in a directory into another directory? What about coping subdirectories too? Thanks in advance for any info
2
3936
by: CCLeasing | last post by:
If (Directory.Exists(@"c:\indigo\" + txtOfficial + @"\" + comOffice.Text + @"\" + numTerm.Value.ToString())) { storereport(); } else { Directory.CreateDirectory(@"c:\indigo\" + txtOfficial +...
4
2809
by: Robert | last post by:
Greetings New to Visual Studio 2008. Always us VB6.0 SP5. I am trying to copy files from A to B. I select a directory, and copy files. Works ok, but it does not create the directory first. ...
4
2552
by: Tom | last post by:
This is really weird, but I have the following code: private static readonly string mString = "tempUnzipDir" + Path.DirectorySeparatorChar; .... public static string...
0
7093
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
7357
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...
1
7012
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...
0
5598
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,...
1
5023
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...
0
3180
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3171
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1522
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
748
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.