Avatar of Frank Bryant
Frank BryantFlag for United States of America asked on

Open a Text Editor from the Command Line Programatically using C#

First let me say that I am a novice when it comes to C#; I am using Visual Studio Enterprise 2015.

I am trying to run a Macro from a Text Editor (Ultraedit) using the Command Line Shell in C# programmatically and I have not been successful.

Here is the text editor Command Line ... uedit32 /fni DriveLetter:\Path\TextFileName.txt /m="DriveLetter:\Path\MacroName.mac" ... I know it works as I ran it from a (Start --> Run) Command Window to test it.

Anyway, here is the problem that I am trying to solve; I have a VERY Large text file which has errors that have to be resolved before it can be imported. This one file is to large to run macros on (out of memory error),  so I have an ultraedit script that takes this very large text file and splits it into several smaller files at 175,000 rows each. I currently have 28 smaller files and four macros to run; 4 x 28 = 112 iterations. I want to automate this process; can it be done?

For what it is worth, here is the C# Code that I am using ...

            // There are 28 Separate Text Files each with 175,000 Data Rows to Be Modified ...
            for (int TheTextFileToBeRead_Loop = 1; TheTextFileToBeRead_Loop <= 28; TheTextFileToBeRead_Loop++)
                for (int TheMacroToBeExecuted_Loop = 0; TheMacroToBeExecuted_Loop <= 3; TheMacroToBeExecuted_Loop++)
                    CmdLineToExecute = @"uedit32 /fni DriveLetter:\Path\TextFileName" + TheTextFileToBeRead_Loop  + ".txt /m=" + (char)34 + @"DriveLetter:\Path\MacroName" + TheMacroToBeExecuted_Loop + ".mac" + (char)34;
                    System.Diagnostics.Process.Start("CMD.exe", CmdLineToExecute);
Editors IDEs

Avatar of undefined
Last Comment
Frank Bryant

8/22/2022 - Mon

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Frank Bryant

Bingo! :)
Frank Bryant

Here is the correct code ...

                    CmdLineToExecute = @"C:\Program Files (x86)\IDM Computer Solutions\UltraEdit\Uedit32.exe"
                    TheArgumentsToPassAre = " /fni DriveLetter:\Path\TextFileName" + TheTextFileToBeRead_Loop  + ".txt /m,e=" + (char)34 + @"DriveLetter:\Path\MacroName" + TheMacroToBeExecuted_Loop + ".mac" + (char)34;

                    System.Diagnostics.Process.Start(TheCommandLineToExecuteIs, TheArgumentsToPassAre);
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.