Directory.CreateDirectory fails

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

The following code:

C# code:
Directory.CreateDirectory("D:\\somewhere\\somewhereelse\\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 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)
 
The following code:

C# code:
Directory.CreateDirectory("D:\\somewhere\\somewhereelse\\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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top