Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1055323
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T17:32:43+00:00 2026-05-16T17:32:43+00:00

Directory.CreateDirectory(@C:\test); Works great. I’m able to create the folder. BUT code below doesn’t work.

  • 0

Directory.CreateDirectory(@”C:\test”);

Works great. I’m able to create the folder. BUT code below doesn’t work.

using System;
using System.IO;
class iolar
{

 public static void klasorOlustur()
 {
  Console.WriteLine("Oluşturmak istediğiniz BİRİNCİ  klasörün adı?");
  string a=Console.ReadLine();
  Console.WriteLine("oluşturmak istediğiniz İKİNCİ klasörün adı?");
  string b=Console.ReadLine();
  Console.WriteLine("Klasörler oluşturuluyor.. Lütfen bekleyin...");

  string klasorYolu="@\"H:\\"+a+"\"";
  string klasorYolu2="\""+b+"\"";

  DirectoryInfo klasorcuk=new DirectoryInfo(klasorYolu);
  Console.Write(klasorYolu);
  if(klasorcuk.Exists==false)
  {
   klasorcuk.Create();
   Console.WriteLine("İlk klasör oluşturuldu...");
   DirectoryInfo klasorcuk2=klasorcuk.CreateSubdirectory(klasorYolu2);
   Console.WriteLine("İkinci klasör de oluşturuldu...");

  }

 }

 static void Main()
 {
  klasorOlustur();
 }
}

I get “Unhandled Exception: System.ArgumentException: Illegal characters in path.” error. I’ve found some stuff about “path class” but I couldn’t get a clear answer.

What should I do?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T17:32:44+00:00Added an answer on May 16, 2026 at 5:32 pm
     string klasorYolu="@\"H:\\"+a+"\"";
    

    Don’t make the string content look like what you write in a C# program. This ought to look more like:

     string klasorYolu = @"H:\" + a;
    

    Be sure to use the Path.Combine() method, it takes care of putting the backslashes in the right place.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am using this to create a new folder System.IO.Directory.CreateDirectory(@ + somevariable); the thing
i am using Directory.CreateDirectory(\\\\MyShared\\Pics\\NewFolder) to create a new folder in the directory \\MyShared\Pics and
I'm new at C#, but I guess I'm using a simple command in Directory.CreateDirectory,
DirectoryInfo dir=new DirectoryInfo(path); if (!dir.Exists) { Directory.CreateDirectory(path); File.Create(path + \\file.xml); StreamWriter sw =new StreamWriter(path
IsolatedStorageFile iF = IsolatedStorageFile.GetUserStoreForApplication(); if (!iF.DirectoryExists(aaa)) { MessageBox.Show(No directory, create!); iF.CreateDirectory(aaa); } StreamWriter fW
Directory.GetFiles(targetDirectory); Using the above code we get the names( i.e full path) of all
Consider this code: string dir = Environment.CurrentDirectory + @\a; Directory.CreateDirectory(dir); FileSystemWatcher watcher = new
Hello guys i am trying to create a folder using c# mvc3. I have
I have troubles with Drupal 7 and file uploading. My code that doesn't work:
Windows 7, python 2.6.6, 2.7 Create directory 'c:\1\test.' Try check if it is dir

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.