0

IO.Path.GetTempFileName() in a c# application it's supposed to create a temp file and return the full path and filename, but the problem that i'm facing is that it ruturns the path with a double slash, just like this:

C:\\Users\\user\\AppData\\Local\\Temp\\tmp4230.tmp

Is it correct? or should it return something like this:

C:\Users\user\AppData\Local\Temp\tmp4230.tmp

thanks in advance

Raidri
  • 17,258
  • 9
  • 62
  • 65
ghfhdfghdfgh
  • 9
  • 1
  • 3
  • 2
    If you're looking at the string in the debugger, it will "helpfully" show all the single backslashes as double backslashes. I suspect that's what's happening. – Matthew Watson Aug 09 '13 at 11:26
  • Those two paths look **exactly the same**. – It'sNotALie. Aug 09 '13 at 11:26
  • Yeah, he's pasted it in wrong I assumed. – Matthew Watson Aug 09 '13 at 11:28
  • Visual studio will show double slashes with its intellisense, If you click the magnifying glass next to the path you are seeing you will see the exact string. (Deleted my answer as it resembled Matthews comment after edit) – Sayse Aug 09 '13 at 11:44

2 Answers2

1

"\" is escape char having "\" in string require to mark it as verbatim or add double "\".

see What is the difference between a regular string and a verbatim string?

Community
  • 1
  • 1
Morbia
  • 4,144
  • 3
  • 21
  • 13
0

It's not, you're just looking in the wrong place. Try to write returned value to the file, you'll see there are no double slash

Vitaly
  • 2,064
  • 19
  • 23