-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfrmDirectoryCustomize.cs
60 lines (48 loc) · 1.88 KB
/
frmDirectoryCustomize.cs
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
using SnowLogCollector.Classes;
using System;
using System.IO;
using System.Windows.Forms;
namespace SnowLogCollector
{
public partial class frmDirectoryCustomize : Form
{
public string FormName { get; set; }
public string DirectoryPath { get; set; }
public string ApplicationDataRoot { get; set; }
public string CollectedLogsRoot { get; set; }
public frmDirectoryCustomize()
{
InitializeComponent();
}
private void frmDirectoryCustomize_Load(object sender, EventArgs e)
{
Text = FormName;
GetDirectories(DirectoryPath);
}
private void GetDirectories(string directory)
{
// get a list of the available directories within the root directory
foreach (var i in Directory.GetDirectories(directory))
{
// get the information about the directory
var dir = new DirectoryInfo(i);
// add it to the listbox to allow checking
clbDirectoryList.Items.Add(dir.Name);
}
}
private void btnGrabData_Click(object sender, EventArgs e)
{
// Create a new instance of the FileCopier
FileCopier fc = new FileCopier();
// Loop through each checked item in the list
foreach (string i in clbDirectoryList.CheckedItems)
{
// Copy the files from the original directory, to the new one, and append the name to
// have the directory name at the start of it
// Because snow have logs called YYYY-MM-DD for some reason
fc.Copy(Path.Combine(DirectoryPath, i), CollectedLogsRoot, i);
}
MessageBox.Show("Data grab finished", Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}