简体   繁体   中英

VB6's equivalent code in C#

This is a sample code which I have to convert in C#. As this code was written long ago and I don't have deep idea about VB, it will be really helpful if a C# version is given.

The code:

ChDir ("c:\folder")
a = Shell("c:\folder\some.exe C /LINK ", 1)        
Sleep 6000   'Implements a 1 second delay
sParameters = "Something"
a = ExecCmd(sParameters)

I have searched on MSDN and saw what Shell does, but I am still confused. Please help me.

Search about

Process.Start("c:\folder\some.ex");

If your app needs arguments :

ProcessStartInfo si= new processStartInfo();
si.fileName="c:\folder\some.exe";
si.CreateNoWindow = false;
si.UseShellExecute = false;

si.WindowStyle = ProcessWindowStyle.Hidden;
si.arguments="arguments here";
try
    {
        // Start the process with the info we specified.
        // Call WaitForExit and then the using statement will close.
        using (Process exeProcess = Process.Start(si))
        {
        exeProcess.WaitForExit();
        }
    }
    catch
    {
        // Log error.
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM