i am trying to declare a string in C#
string
writePath,
billMonth,
startPath = '\\filervoca\groups\edit\public' ;
for startPath i get an error for either ' or " im not sure how to intalize thie value to this network folder.
thanks
crash
Printable View
i am trying to declare a string in C#
string
writePath,
billMonth,
startPath = '\\filervoca\groups\edit\public' ;
for startPath i get an error for either ' or " im not sure how to intalize thie value to this network folder.
thanks
crash
declare your string as
I beleive the single \ is an escape clause and by either putting a double \\ or by placing the @ before the path it turns it into a literal(sp) path.Code:public string startPath = "\\filervoca\\groups\\edit\\public" ;
or
public string startPath2 = @"\\filervoca\groups\edit\public";
I'm sure others will correct my example but the code working in my test.
Al
4 \s to get \\ ;)Code:public string startPath = "\\\\filervoca\\groups\\edit\\public" ;
Good shout Harsh Gupta!Quote:
Originally Posted by Harsh Gupta
:D
I remember when they told me to do things the easy way
Code:string startPath = @"\\filervoca\groups\edit\public";
Works thanks
If you have only escape backslashes in a string then don't use the verbatim operator, e.g.If you have only literal backslashes in a string then do use the verbatim operator, e.g.Code:myTextBox.Text = "line 1\nline 2";
If you have both escape and literal backslashes then don't use the verbatim operator and do escape your literal backslashes, e.g.Code:myTextBox.Text = @"The path is C:\Files\MyFile.txt";
Code:myTextBox.Text = "The path is as follows:\n\"C:\\Files\\MyFile.txt\"";