namespace ConsoleApplication1 { class Program { static string SteamLogFilePath; static void Main(string[] args) { try { getSteam3id(); Console.ReadLine(); } catch { Console.WriteLine("steam not installed"); Console.ReadLine(); } } public static void getSteam3id() { string tmpFile = "TMPsteam.txt"; string tmp; string[] tmpSplit1; RegistryKey registryKey = Registry.CurrentUser.OpenSubKey(@"Software\Valve\Steam"); string pathName = (string)registryKey.GetValue("SteamPath"); pathName = pathName.Replace("/", ""); SteamLogFilePath = pathName + "\\logs\\connection_log.txt"; TextReader tr = null; try { File.Copy(SteamLogFilePath, tmpFile, true); } catch { } try { tr = new StreamReader(tmpFile); try { while (true) { tmp = tr.ReadLine(); if (tmp.Contains("RecvMsgClientLogOnResponse") && tmp.Contains("OK")) { tmpSplit1 = tmp.Split(')'); string SteamIdbrut = tmpSplit1[1]; tmpSplit1 = SteamIdbrut.Split(']'); string SteamIdnet = tmpSplit1[0].Replace(" : [", ""); Console.WriteLine("STEAM 3 ID : " + SteamIdnet); } // А как записать в файл ? чтобы было так // SteamID: number. } } catch { } } catch { } if (tr != null) tr.Close(); } } }
public string[] getSteamIDs() { List<string> idsOutput = new List<string>(); RegistryKey registryKey = Registry.CurrentUser.OpenSubKey(@"Software\Valve\Steam"); string pathName = (string)registryKey.GetValue("SteamPath"); string[] rawLog = File.ReadAllLines(pathName + "//logs//connection_log.txt"); string[] selectedLog = rawLog.Where(x => x.IndexOf("RecvMsgClientLogOnResponse") != -1 && x.IndexOf("OK") != -1).ToArray(); for (int i = 0; i < selectedLog.Length; i++) { string id = selectedLog[i].Split('[', ']')[5]; if (!idsOutput.Contains(id)) { idsOutput.Add(id); } } return idsOutput.ToArray(); }
string[] parsedIds = getSteamIDs(); StreamWriter SW = new StreamWriter("tmpLog.txt"); for (int i = 0; i < parsedIds.Length; i++) { SW.WriteLine(parsedIds[i]); } SW.Close();
public string[] getSteamIDs() { List<string> idsOutput = new List<string>(); RegistryKey registryKey = Registry.CurrentUser.OpenSubKey(@"Software\Valve\Steam"); string pathName = (string)registryKey.GetValue("SteamPath"); string[] rawLog = File.ReadAllLines(pathName + "//logs//connection_log.txt"); for (int i = 0; i < rawLog.Length; i++) { if (rawLog[i].IndexOf("RecvMsgClientLogOnResponse") != -1 && rawLog[i].IndexOf("OK") != -1) { string id = rawLog[i].Split('[', ']')[5]; if (!idsOutput.Contains(id)) { idsOutput.Add(id); } } } return idsOutput.ToArray(); }