views:

196

answers:

3

Hi, I am using a relative file path in one of the cs file to get a location to save an image.

Is there any difference in using ../ and ..// for getting the path.

A: 

There shouldn't be, though I don't know about with ASP.NET. Are you having trouble with it?

jtbandes
+1  A: 

On Unix, and I think MS-DOS and hence Windows follows Unix closely enough here that it is not a difference between the systems, then you can have any number of consecutive slashes at any point in a pathname and it is equivalent to a single slash. Consequently, your two examples are equivalent.

Note that on Windows, a double slash at the start of a path name indicates a UNC path - a machine name followed by a path on that machine.

Jonathan Leffler
+1  A: 

I don't know if your slashes are actually backslashes, but in c#, you have to escape backslashes.

var path = "..\\file.txt";

path's value is actually ..\file.txt, because the "\" is actually one (escaped) backslash.

However, if it is:

var path = @"..\file.txt";

then it is the same. The @ means you want the string as-is, without any escaping, so both "path" variables are the same.

Kevin