The problem is in your startup.SetValue()
. You are escaping a "
character and I think you want to escape a \
:
startup.SetValue("My_Application", "\\" + newpath);
If you actually mean to escape a "
then you probably need one on both sides:
startup.Setvalue("My_Application", "\"" + newpath + "\"");
Or Typically this should work (I'm not super familiar with this API)
startup.SetValue("My_Application", newpath);