Reading the output of windows batch file from c# -


i have requirement have check size of file using windows batch file , read output c# code

batch-script

@echo off set maximumbytesize=1000 setlocal enabledelayedexpansion /f  %%a in ('dir /b d:\test_batch_files') (   set name=%%a   set size=%%~za   if  !size! gtr !maximumbytesize! (     echo greater   ) else (     echo smaller   ) ) 

c# code output:

 process p = new process();             p.startinfo.useshellexecute = false;             p.startinfo.redirectstandardoutput = true;             p.startinfo.filename = "d:\\test_batch_files\\getfilesizeindirectory.bat";             //configurationmanager.appsettings["batchscriptpath"].tostring();                                p.start();             streamreader mystreamreader = p.standardoutput;              mystring = mystreamreader.readtoend();             p.waitforexit(); 

the output running batch should (running cmd):

smaller smaller smaller greater smaller smaller smaller smaller smaller smaller 

the output c#

smaller smaller smaller smaller smaller smaller smaller smaller smaller smaller    


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -