Advertisement
njunwa1

Untitled

Sep 1st, 2016
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.33 KB | None | 0 0
  1.  
  2.         private void btnConnect_Click(object sender, EventArgs e)
  3.         {
  4.  
  5.  
  6.             //using (var fileStream = new FileStream(logpath, FileMode.Open, FileAccess.Write, FileShare.Read))
  7.             var proc = new Process
  8.             {
  9.                 StartInfo = new ProcessStartInfo
  10.                 {
  11.                     FileName = Application.StartupPath + "\\bin\\openvpn.exe",
  12.                     Arguments = "--config .\\bin\\vpnconfig.ovpn http-proxy 127.0.0.1 8000 --log logfile.txt",
  13.                     UseShellExecute = false,
  14.                     CreateNoWindow = true
  15.                 }
  16.             };
  17.  
  18.             proc.Start();
  19.          
  20.             ShowLog();
  21.         }
  22.  
  23.         private void ShowLog()
  24.         {
  25.             using (var fileStream = new FileStream(logpath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
  26.             using (TextReader reader = new StreamReader(fileStream))
  27.             {
  28.  
  29.                 rtbLog.Text = "";
  30.                 string line = reader.ReadLine();
  31.  
  32.                 while (line != null)
  33.                 {
  34.                     rtbLog.AppendText(line + '\n');
  35.                     rtbLog.ScrollToCaret();
  36.                     Thread.Sleep(3000);
  37.                     line = reader.ReadLine();
  38.                 }
  39.                 reader.Close();
  40.             }
  41.  
  42.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement