Reputation: 349
ProcessStartInfo procStartInfo = new ProcessStartInfo("cmd", "/c " + "MyExecutable.exe");
procStartInfo.RedirectStandardOutput = true;
procStartInfo.UseShellExecute = false;
procStartInfo.CreateNoWindow = true;
Process proc = new Process();
proc.StartInfo = procStartInfo;
proc.Start();
I have an executable in my project, say "MyExecutable.exe". When running this application, it will create a log file in the same path where this exe
is executed.
If I run this exe
in command prompt, I have no issues.
But If I run the exe from c# code, it is throwing error "File/Access Error" in the below code which is in MyExecutable.exe
Open `sLogfile` For Output Access Write As `LogFileNumber`
where sLogfile
is the logfile
name and LogFileNumber
is the FreeFile
.
Upvotes: 1
Views: 98
Reputation: 1144
Current guidance says to not write logs into an executable directory. This is probably Windows enforcing this guidance. Write to the user's AppData
directory instead.
Upvotes: 4