newgie string help please

  • Thread starter Thread starter darren
  • Start date Start date
D

darren

hi iam righting aprogram that creates its own desktop shotcut and a
want to add a command line switch

so i want to have a string like this

"C:\Documents and Settings\Darren\My Documents\Visual Studio
Projects\shorcut\bin\Debug\shorcut.exe" /r"

my problem is how do i get the single " quote mark into my string
please help

thanks
Darren
 
Hi that line gets me a unrecognized escape sequence error

string s = "\"C:\Documents and Settings\Darren\My Documents\Visual
Studio Projects\shorcut\bin\Debug\shorcut.exe\" /r";

regards
Darren
 
hi this just gives more errors

Read the docs on strings you really must. Try this:

string s = "\"C:\\Documents and Settings\\Darren\\My Documents\\Visual
Studio Projects\\shorcut\\bin\\Debug\\shorcut.exe\\" /r";
 
hi ok thank for the ideas so far here is my small test program if
anyone can help that would be great i just want to make a
desktopshortcut whic also passes \r

regards
Darren
 
hi ok thank for the ideas so far here is my small test program if
anyone can help that would be great i just want to make a
desktopshortcut whic also passes \r

regards
Darren
 
hi ok thank for the ideas so far here is my small test program if
anyone can help that would be great i just want to make a
desktopshortcut whic also passes \r

regards
Darren
 
Darren-

By escaping it;

string s = "can you find the \" extra quote?";

But, if you add a quote to you string in the place you indicated, you will
have unbalanced quotes. What you want is for you string to look like this;

"C:\Documents and Settings\Darren\My Documents\Visual Studio
Projects\shorcut\bin\Debug\shorcut.exe" /r

So you would assign the string like this:

string s = "\"C:\Documents and Settings\Darren\My Documents\Visual Studio
Projects\shorcut\bin\Debug\shorcut.exe\" /r";



HTH
Brian W
 
darren said:
Hi that line gets me a unrecognized escape sequence error

Read the docs on strings you really must. Try this:

string s = "\"C:\\Documents and Settings\\Darren\\My Documents\\Visual
Studio Projects\\shorcut\\bin\\Debug\\shorcut.exe\\" /r";
 
try this

string s = @"""C:\Documents and Settings\Darren\My Documents\Visual
Studio Projects\shorcut\bin\Debug\shorcut.exe\"" /r";
 
copy and paste error ... don't include the last \
string s = @"""C:\Documents and Settings\Darren\My Documents\Visual
Studio Projects\shorcut\bin\Debug\shorcut.exe\"" /r";

string s = @"""C:\Documents and Settings\Darren\My Documents\Visual
Studio Projects\shorcut\bin\Debug\shorcut.exe"" /r";
 
NOTE: ur program need one argument to run, since u have
if (args.Length == 1) restriction in the main function
if you don't want to impose this restriction simply remove the if statement

regard to the program itself

u need to change the value of the textbox to
"C:\Documents and Settings\Darren\My Documents\Visual Studio
Projects\shorcut\bin\Debug\shorcut.exe" /r
because this is the actual command for shortcut


and change the s variable to
string s = @"""C:\Documents and Settings\Darren\My Documents\Visual Studio
Projects\shorcut\bin\Debug\shorcut.exe""";
beause link.cs only need this to figure out what is the name for your
shortcut

Link.Update(Environment.SpecialFolder.DesktopDirectory,textBox1.Text, s
,true);

hope this help
 
Back
Top