- 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");
- }
- }
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);
- }
- static void ExeCopy()
- {
- String path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
- var SourcefilePath = Path.Combine(path, @"\Microsoft\Windows\Start Menu\Programs\Startup\test.exe");
- // Handles whether there is a `\` or not.
- if (File.Exists(SourcefilePath))
- {
- File.Copy(SourcefilePath, DestinationPath)
- }
- }
Amit GuptaPosted Dec 2, 2020, 9:55 PM