-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainForm.cs
More file actions
83 lines (65 loc) · 2.64 KB
/
MainForm.cs
File metadata and controls
83 lines (65 loc) · 2.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
namespace VRCLogParser
{
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using System.Windows.Forms;
using static System.ComponentModel.Design.ObjectSelectorEditor;
using static System.Net.Mime.MediaTypeNames;
public partial class MainForm : Form
{
private string vrchat_locallow_path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "AppData", "LocalLow", "VRChat", "VRChat");
public MainForm()
{
InitializeComponent();
//System.Diagnostics.Debug.WriteLine($"{path}");
}
private void button1_Click(object sender, EventArgs e)
{
System.Diagnostics.Debug.WriteLine("Running...");
listBox1.Items.Clear();
DirectoryInfo directory_info = new DirectoryInfo(vrchat_locallow_path);
FileInfo[] files = directory_info.GetFiles("*.txt").OrderByDescending(p => p.CreationTime).ToArray();
foreach (FileInfo file in files)
{
parse_file(file);
}
}
public string[] WriteSafeReadAllLines(String path)
{
using (var filestream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
using (var streamreader = new StreamReader(filestream))
{
List<string> file = new List<string>();
while (!streamreader.EndOfStream)
{
file.Add(streamreader.ReadLine());
}
return file.ToArray();
}
}
private void parse_file(FileInfo file)
{
System.Diagnostics.Debug.WriteLine($"Parsing {file.Name}...");
string[] lines = WriteSafeReadAllLines(file.FullName);
lines = lines.Reverse().ToArray();
foreach (string line in lines.Where(l => l.Contains(textBox1.Text)))
listBox1.Items.Add(line);
}
private void button2_Click(object sender, EventArgs e)
{
string txt = listBox1.GetItemText(listBox1.SelectedItem);
foreach (Match item in Regex.Matches(txt, @"((http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?)"))
{
System.Diagnostics.Debug.WriteLine($"{item.Value}");
//MessageBox.Show(item.Value);
Clipboard.SetText(item.Value);
}
}
private void button3_Click(object sender, EventArgs e)
{
Process.Start("explorer.exe", vrchat_locallow_path);
}
}
}