Creating a file path in C#

Posted by Jason on Stack Overflow See other posts from Stack Overflow or by Jason
Published on 2010-05-22T19:52:01Z Indexed on 2010/05/22 20:00 UTC
Read the original article Hit count: 136

Filed under:
|

So I'm trying to create a path in C#. I use Environment.Machinename and store it a variable serverName. Then I create another string variable and have some other path extension in there. Here is my code so far:

string serverName = Environment.MachineName;
string folderName = "\\AlarmLogger";

No matter what I do I can't seem to obtain only one backslash prior to AlarmLogger. Any ideas how I can specify a path in C#?

Edit: I'm wondering if my code doesn't seem to want to paste correctly. Anyways when i paste it I only see one backslash but my code has two. Because of the escape character sequence. But something like

string test = @"\" + serverName + folderName

doesn't seem to want to work for me.

© Stack Overflow or respective owner

Related posts about c#

Related posts about file-io