Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.IO;
- using System.Net;
- using System.Text.RegularExpressions;
- namespace Pinger
- {
- class LogReader
- {
- public StreamReader GetStreamReaderFromRemotePC(string ip)
- {
- var userName = "Администратор";
- var password = "Vfdnjpfdh2016";
- var filePath = $@"\\{ip}\C$\UTM\monitoring\l\monitor.log";
- var destinationPath = Path.Combine(Environment.CurrentDirectory, $"log\\monitor{ip}.log");
- NetworkCredential networkCredential = new NetworkCredential(userName, password);
- CredentialCache netCache = new CredentialCache
- {
- { new Uri($@"\\{ip}"), "Basic", networkCredential }
- };
- if (File.Exists(destinationPath)) File.Delete(destinationPath);
- File.Copy(filePath, destinationPath);
- return new StreamReader(destinationPath);
- }
- public string GetSmartCardVersion(StreamReader sr)
- {
- var line = String.Empty;
- while ((line = sr.ReadLine()) != null)
- {
- if (line.Contains("Найден слот"))
- {
- var regex = new Regex(@"\[([^\[\]]+)\]");
- var match = regex.Matches(line);
- return match[0].ToString().Substring(3, match[0].ToString().Length-4).Trim();
- }
- }
- return String.Empty;
- }
- }
- }
Add Comment
Please, Sign In to add comment