- static void ExeCopy()
- {
- if (!File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\Microsoft\Windows\Start Menu\Programs\Startup\securpass.exe"))
- {
- File.Copy(Path.GetFileName(Application.ExecutablePath), Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\Microsoft\Windows\Start Menu\Programs\Startup\securpass.exe");
- }
- }
Hi, I'm trying to get a copy of my application to the launch folder.
However, although I did not get an error, my code block does not work and my file is not copied.
I would be happy if you could help.
- static void ExeCopy()
- {
- RegistryKey registryKey = Registry.CurrentUser.OpenSubKey
- ("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
- registryKey.SetValue("test.exe", Application.ExecutablePath);
- }
I added the above code block to my project. But my problem persists. The code block is error free but doesn't work.
- static void ExeCopy()
- {
- String path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
- var SourcefilePath = Path.Combine(path, @"\Microsoft\Windows\Start Menu\Programs\Startup\test.exe");
-
- if (File.Exists(SourcefilePath))
- {
- File.Copy(SourcefilePath, DestinationPath)
- }
- }
I've added the above code block to my project. I get an error in the DestinationPath section. What is DestinationPath?