Path

S

shapper

Hello,

I am uploading a few files and saving the path of where they are
placed on a SQL table. For example:

Contents/Documents/c6bdf8ed-3139-41a9-a3b9-7b966fabbd32.pdf

I am renaming the file using the id (Guid) of the record inserted on
the database.

However, sometimes, when I get a path using Microsoft library I get
something like:
c:\\Project\WebSite\\Contents\\Documents

Should I create my path using \\?

I never know how to create a path because I always see many formats.

Thanks,
Miguel
 
J

Jon Skeet [C# MVP]

However, sometimes, when I get a path using Microsoft library I get
something like:
c:\\Project\WebSite\\Contents\\Documents

Should I create my path using \\?

You need to be clear about the difference between how you see a string
in the debugger (or in source code) and what's *actually* in the
string. Where are you seeing the above, with double slashes?

See http://pobox.com/~skeet/csharp/strings.html for more about this,
btw.

Jon
 
J

Jon Skeet [C# MVP]

However, sometimes, when I get a path using Microsoft library I get
something like:
c:\\Project\WebSite\\Contents\\Documents

Should I create my path using \\?

You need to be clear about the difference between how you see a string
in the debugger (or in source code) and what's *actually* in the
string. Where are you seeing the above, with double slashes?

See http://pobox.com/~skeet/csharp/strings.html for more about this,
btw.

Jon
 
S

shapper

You need to be clear about the difference between how you see a string
in the debugger (or in source code) and what's *actually* in the
string. Where are you seeing the above, with double slashes?

Seehttp://pobox.com/~skeet/csharp/strings.htmlfor more about this,
btw.

Jon

Ah ok ... I have the following:

string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory,
file.Path);

file.Path is from a Linq query that takes the path from the database.

I get on the debugger, when placing the mouse over the variable:
C:\\Documents and Settings\\Miguel\\My Documents\\Projects\\BonsAlunos\
\Project\\Website\\Contents/Engine/Document/c6bdf8ed-3139-41a9-
a3b9-7b966fabbd32.pdf

And on Text visualizer:
C:\Documents and Settings\Miguel\My Documents\Projects\BonsAlunos
\Project\Website\Contents/Engine/Document/c6bdf8ed-3139-41a9-
a3b9-7b966fabbd32.pdf

Why the difference between \\ and \?

And should I use \ on my path instead of / ?

Thanks,
Miguel
 
D

DH

shapper said:
Ah ok ... I have the following:

string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory,
file.Path);

file.Path is from a Linq query that takes the path from the database.

I get on the debugger, when placing the mouse over the variable:
C:\\Documents and Settings\\Miguel\\My Documents\\Projects\\BonsAlunos\
\Project\\Website\\Contents/Engine/Document/c6bdf8ed-3139-41a9-
a3b9-7b966fabbd32.pdf

And on Text visualizer:
C:\Documents and Settings\Miguel\My Documents\Projects\BonsAlunos
\Project\Website\Contents/Engine/Document/c6bdf8ed-3139-41a9-
a3b9-7b966fabbd32.pdf

Why the difference between \\ and \?

And should I use \ on my path instead of / ?

Thanks,
Miguel
The reason you see \\ instead of \ in the debugger the \ key used for
escape characters such as \t for tab.
more here http://blogs.msdn.com/csharpfaq/archive/2004/03/12/88415.aspx
therefore in the debugger you see \\ instead of \ so you can tell the
difference for example if you had something like
....\Think you don't misinterpret it as \T (tab) hink.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

String and Path 2
Path 2
MSBuild. How to get project path? 1
Load XML file 3
Check extension 5
Class and XML file. Very strange problem. 1
Save files on SQL 2008. Need advice 3
VS.NET get item path 1

Top