I have written an executable that copies files from a networklocation to a folder in Program Files. When I run this normally (as administrator), everything goes fine. However, when running it as a startup program, execution suddenly stops.
There is no exception thrown (to my knowledge, I have included logging which works when executing normally). It just seems as it stops running; I have added a messagebox to be shown after execution but this will not work.
Is there any solution in code or in settings to get my startup-program to write to the Program Files?
I can provide code if needed, but it's just a simple file.CopyTo()
method. The exact path is: C:\Program Files (x86)\Microsoft Visual Studio 11.0\Team Tools\Static Analysis Tools\FxCop\Rules
Additional code:
string sourceLocation = ConfigurationManager.AppSettings["sourceLocationCodeAnalysisRules"];
DirectoryInfo sourceDir = new DirectoryInfo(sourceLocation);
sourceDir
.GetFiles()
.Where(file => file.LastWriteTime > new FileInfo(Path.Combine(deployDir.FullName, file.Name)).LastWriteTime)
.ForEach(file => file.CopyTo(Path.Combine(deployDir.FullName, file.Name), true));
}
The purpose of this executable is to check the networklocation for newer files, and if they are newer, copy them to the given location. So an installer is not something I need.