-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathfrmFileFolder.cs
More file actions
96 lines (83 loc) · 2.82 KB
/
Copy pathfrmFileFolder.cs
File metadata and controls
96 lines (83 loc) · 2.82 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
84
85
86
87
88
89
90
91
92
93
94
95
96
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace MountBladeModPacker
{
public partial class frmFileFolder : Form
{
private FolderFile folderFile;
private List<string> folders;
private List<string> files;
private string currentDir;
public FolderFile SelectedFolderFile { get { return folderFile; } }
public frmFileFolder(string currentDir)
{
InitializeComponent();
folders = new List<string>();
files = new List<string>();
refreshFileFolders(currentDir);
}
private void refreshFileFolders(string currentDir)
{
this.currentDir = currentDir;
folders.Clear();
files.Clear();
DirectoryInfo di = new DirectoryInfo(currentDir);
foreach(var fileFolderItem in di.GetFileSystemInfos())
{
if ((fileFolderItem.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden)
continue;
if ((fileFolderItem.Attributes & FileAttributes.Directory) == FileAttributes.Directory)
{
folders.Add(fileFolderItem.Name);
}
else
{
files.Add(fileFolderItem.Name);
}
}
folders.Sort();
files.Sort();
foreach(var folder in folders)
{
ListViewItem item = new ListViewItem();
item.Text = folder;
item.SubItems.Add("Folder");
item.ImageIndex = 0;
listDirectory.Items.Add(item);
}
foreach (var file in files)
{
ListViewItem item = new ListViewItem();
item.Text = file;
item.SubItems.Add("File");
item.ImageIndex = 1;
listDirectory.Items.Add(item);
}
}
private void btnOK_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.OK;
var item = listDirectory.SelectedItems[0];
FolderFile folderFile = new FolderFile();
folderFile.Name = item.Text;
if (item.SubItems[1].Text == "Folder")
folderFile.Type = FolderFileType.Folder;
else if(item.SubItems[1].Text == "File")
folderFile.Type = FolderFileType.File;
this.folderFile = folderFile;
Close();
}
private void btnCancel_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}
}
}