[尝试从c#调用VB6应用程序时出现文件/访问错误

问题描述 投票:1回答:1
        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();

我的项目中有一个可执行文件,说“ MyExecutable.exe”。运行此应用程序时,它将在执行此exe的相同路径中创建一个日志文件。

如果我在命令提示符下运行此exe,则没有问题。

但是如果我从C#代码运行exe,则会在下面的MyExecutable.exe中的代码中引发错误“文件/访问错误”>

Open `sLogfile` For Output Access Write As `LogFileNumber`

其中sLogfilelogfile名称,LogFileNumberFreeFile

ProcessStartInfo procStartInfo = new ProcessStartInfo(“ cmd”,“ / c” +“ MyExecutable.exe”); procStartInfo.RedirectStandardOutput = true; procStartInfo.UseShellExecute = false; ...

c# vb6
1个回答
3
投票

[当前指导说不要将日志写入可执行文件目录。这可能是Windows强制执行此指南。改为写入用户的AppData目录。

© www.soinside.com 2019 - 2024. All rights reserved.