0

I tried many solutions but I fail.

I know that there is a problem with spaces and I can add @ or /" or "" (but double quotes in code lead to compiler errors)

This is my code:

string dirAppData = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
string sciezka = @"Microsoft\Windows\Menu Start\Programs\Startup";
string path = dirAppData + "\\" + sciezka;
System.Diagnostics.Process.Start("explorer.exe", path);  // did not work (wrong path)
string sciezka1 = 
    @"C:\Users\Piotr\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup";
System.Diagnostics.Process.Start("explorer.exe", sciezka1);  // works

How should I write in path that it works in the first case?

Wolf
  • 9,679
  • 7
  • 62
  • 108
  • Put quotes around it - " - try either \" or "" – mjwills Jan 13 '21 at 12:48
  • 2
    One path has "menu start" and the other "start menu"... – Mark PM Jan 13 '21 at 12:49
  • Does this answer your question? [how to handle spaces in file path if the folder contains the space?](https://stackoverflow.com/questions/6521546/how-to-handle-spaces-in-file-path-if-the-folder-contains-the-space) –  Jan 13 '21 at 12:53
  • 1
    I would also suggest using `Path.Combine` when merging paths, at least if you want your code to be portable. – JonasH Jan 13 '21 at 12:55
  • Does this answer your question? [Escape double quotes in a string](https://stackoverflow.com/questions/14480724/escape-double-quotes-in-a-string) – Wolf Jan 13 '21 at 13:04
  • Thank You. I was mistake with Menu Start and Start Menu. – Piotr Juszczyk Jan 13 '21 at 13:06

1 Answers1

0

it's just an typp :D

the first path is wrong.

string sciezka = @"Microsoft\Windows\Menu Start\Programs\Startup";

it should be

string sciezka = @"Microsoft\Windows\Start Menu\Programs\Startup";

regards

Maetti79
  • 46
  • 1