We help IT Professionals succeed at work.

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

Frank Bryant
Frank Bryant asked
Last Modified: 2016-02-26
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);
Watch Question

Freelance programmer / Consultant
This one is on us!
(Get your first solution completely free - no credit card required)


Bingo! :)


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);
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.