Advertisement
Guest User

Untitled

a guest
Jan 1st, 2019
303
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.95 KB | None | 0 0
  1. using System;
  2. using System.Text;
  3. using System.IO;
  4. using System.Text.RegularExpressions;
  5.  
  6. namespace gigatools {
  7.     public class Parser {
  8.         public static int Main(string[] argv) {
  9.             StringBuilder output = new StringBuilder();
  10.            
  11.             string file = argv[0];
  12.             using (StreamReader reader = new StreamReader(file)) {
  13.                 while (reader.Peek() >= 0) {
  14.                    
  15.                     string line = reader.ReadLine();
  16.                     int loginIndex = 0;
  17.                     int startIndex = 0;
  18.                    
  19.                     if ((loginIndex = line.IndexOf("Login:")) == -1) {
  20.                         continue;
  21.                     }
  22.                    
  23.                     startIndex = line.IndexOf(": ") + 2;
  24.                    
  25.                     string data = line.Substring(startIndex);
  26.                     string[] delimiters = data.Split(':');
  27.                    
  28.                     string username = delimiters[0];
  29.                     string password = delimiters[1];
  30.                    
  31.                     output.AppendFormat("Username: {0}\r\nPassword: {1}\r\n\r\n", username, password);
  32.                 }
  33.             }
  34.            
  35.             File.WriteAllText("output.txt", output.ToString());
  36.             return 0;
  37.         }
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement