Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to get or set value while parsing a log file
    text
    copied!<p>Hi I am trying to get the number of files copied value from a logfile produce by a RoboCopy method within my application. The logfile is always in this format:</p> <hr> <h2> ROBOCOPY :: Robust File Copy for Windows :: Version XP010</h2> <p>Started : Thu Oct 10 10:08:51 2013</p> <p>Source : \ad\nas\Dev_Code\ITA\Stats\11.6.4.15\CFI\Build\ Dest : C:\inetpub\CFI\</p> <pre><code>Files : *.* </code></pre> <p>Options : <em>.</em> /FFT /NFL /TEE /S /E /COPY:DAT /Z /IS /R:5 /W:5 </p> <hr> <pre><code> 1 \\ad\nas\Dev_Code\ITA\Stats\11.6.4.15\CFI\Build\ </code></pre> <hr> <pre><code> Total Copied Skipped Mismatch FAILED Extras Dirs : 1 0 1 0 0 0 **Files : 1** 1 0 0 0 0 Bytes : 1.62 m 1.62 m 0 0 0 0 Times : 0:00:03 0:00:02 0:00:00 0:00:00 Speed : 607364 Bytes/sec. Speed : 34.753 MegaBytes/min. Ended : Thu Oct 10 10:08:59 2013 </code></pre> <p>So far I am able to read the file into a streamreader but is there anything I can do to ensure I am always selecting the last instance of Files : and then the value under the Total column i.e. 1</p> <pre><code>try { // Open file for reading. using (StreamReader r = new StreamReader(@"C:\LogFile.log")) { // 2. // Read each line until EOF. string line; while ((line = r.ReadLine()) != null) { // 3. // Do stuff with line. if (line.Contains("Files")) { String content = line.ToString(); char sep = '\t'; string[] splitContent = content.Split(sep); Console.WriteLine(splitContent); } } } } catch (Exception) { throw; } </code></pre> <p>Output at the min = System.String[]</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload