2

I have to create a directory using some Korean characters the end text becomes something like :

2016.07.12 09:20(제휴) 캠블리 영어 완성 1+1 이벤트

I am using this to create directory:

 Directory.CreateDirectory(folderpath + "\\" + dName);

But i get Error :

The given path's format is not supported."

But if i manually go to explorer create new folder paste that text it takes it fine and makes a new directory any suggestion ?

4
  • what is the value for folderpath and dName Commented Jul 12, 2016 at 1:56
  • Read msdn.microsoft.com/en-us/library/aa365247 Commented Jul 12, 2016 at 1:56
  • paths are correct if i just use dname= test it works fine , when i use dname as the value above i get the error.\ Commented Jul 12, 2016 at 1:57
  • 2
    Aside: use Path.Combine() instead of concatenation of strings with the double back slash. Commented Jul 12, 2016 at 2:06

2 Answers 2

4

In Windows, the : character isn't supported in file paths.

This MSDN page lists the characters that cannot be used in paths:

Use any character in the current code page for a name, including Unicode characters and characters in the extended character set (128–255), except for the following:

The following reserved characters:

  • < (less than)
  • > (greater than)
  • : (colon)
  • " (double quote)
  • / (forward slash)
  • \ (backslash)
  • | (vertical bar or pipe)
  • ? (question mark)
  • * (asterisk)

  • Integer value zero, sometimes referred to as the ASCII NUL character.

  • Characters whose integer representations are in the range from 1 through 31, except for alternate data streams where these characters are allowed. For more information about file streams, see File Streams.
  • Any other character that the target file system does not allow.
Sign up to request clarification or add additional context in comments.

3 Comments

But as i said paste the above and it works when you do manually maybe i ignore the : let me check again
@confusedMind I'm not sure why explorer lets you create that, as it shouldn't. Maybe it's a full width colon or something like that that is being created when you enter it in manually?
You are rite : is not allowed maybe i remove it on explorer, if i remove on the code it works fine thank you for pointing that out
1

What do you get when trying to print folderpath + "\\" + dName? is it the full path and requested directory name?

Refer to the examples provided at https://msdn.microsoft.com/en-us/library/54a0at6s(v=vs.110).aspx and make sure you formatted the path correctly.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.