0

I have a problem with saving. I need to images which path's are longer than the 260 characters (Sadly they have to be this long. Not my idea!)

I found this one here: https://blogs.msdn.microsoft.com/bclteam/2007/03/26/long-paths-in-net-part-2-of-3-long-path-workarounds-kim-hamilton/

I tried the \?\ but it didn't work.

My path is: "\\?\D:\Temp1\Data\" In this case Visual Studio says that there is an unknown escape sequence.

Code:

RootDir = "\\?\"+RootDir;

Exception: None. Visual Studio simply says there is an unknown escape sequenz

Then i tried @"\\?\D:\Temp1\Data" Visual Studio says that there is a sign which is not allowed. I guess it is the "?" Code:

RootDir = @"\\?\"+RootDir;

Exception: illegal character in path. Maybe this helps in this case: System.Security.Permissions.FileIOPermission.CheckIllegalCharacters(String[] str)

And when I try it without the \\?\ there is the windows exception which says that the Path only allows 260 characters.

What mistake/s did i do?

I hope you can help me.

Best regards Richard

What I have tried:

These links: https://blogs.msdn.microsoft.com/bclteam/2007/03/26/long-paths-in-net-part-2-of-3-long-path-workarounds-kim-hamilton/

https://msdn.microsoft.com/en-us/library/aa365247.aspx

Evosoul
  • 197
  • 1
  • 12

2 Answers2

0

Long path prefix has two slashes, not one

string longPath = @”\\?\” + fileName;

UDT: Look at this question and this lib

Also check this

According to these posts, you shoul use winAPI to handle long paths

Community
  • 1
  • 1
Daniil Vlasenko
  • 457
  • 3
  • 11
0

According to the link you posted, you have to write the path with 2 backslashes before the question mark

So the path should look like this

@"\\?\D:\Temp1\Data"

Or This

"\\?\D:\Temp1\Data"
Hynek Bernard
  • 744
  • 1
  • 11
  • 30
  • Sry, I did the \\?\ not the \?\. Stackoverflow swallowed one. I changed it in the question – Evosoul Jun 27 '16 at 11:24
  • It is just a thought, have you tried using '\\\?\' ? I mean you will escape the backslash, then you will escape the question mark. – Hynek Bernard Jun 27 '16 at 13:53