-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFileSelecter.cs
More file actions
109 lines (103 loc) · 3.21 KB
/
FileSelecter.cs
File metadata and controls
109 lines (103 loc) · 3.21 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
97
98
99
100
101
102
103
104
105
106
107
108
109
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using WWHDR_configloader.Properties;
namespace WWHDR_configloader
{
public partial class FileSelecter : Form
{
ReadFolder f;
Form1 parent;
public string path;
public FileSelecter(Form1 _parent)
{
InitializeComponent();
f = new ReadFolder();
parent = _parent;
}
string removeLastDir(string path)
{
if (path.Contains("/"))
{
return path.Substring(0, path.LastIndexOf("/"));
}
else if (path.Contains("\\"))
{
return path.Substring(0, path.LastIndexOf("\\"));
}
else
{
return path;
}
}
private bool Check()
{
var install = "/storage_mlc/usr/title/00050000/10143599";
if (Properties.Settings.Default.gameinstall == "usb")
{
install = "/storage_usb/usr/title/00050000/10143599";
}
string p = install + customPath.Text;
(string[] wiiu, List<DateTime> date) = f.readWiiUFolder(removeLastDir(p), 1000);
string file = p.Substring(p.LastIndexOf("/") + 1);
if (customPath.Text == string.Empty)
{
MessageBox.Show("The Wii U file path is empty!");
return false;
}
if (!file.Contains("."))
{
fileExists.Visible = false;
MessageBox.Show("The Wii U file path shouldn't be a folder!");
return false;
}
for (int i = 0; i < wiiu.Length; i++)
{
if (wiiu[i] == file)
{
fileExists.Visible = true;
return true;
}
}
fileExists.Visible = false;
MessageBox.Show("Wii U file not found. Make sure the path is correct and follows the example.");
return false;
}
private void check_Click(object sender, EventArgs e)
{
Check();
}
private void add_Click(object sender, EventArgs e)
{
if (Check())
{
if (!File.Exists(fileTextbox.Text))
{
MessageBox.Show("PC file not found. Make sure the path is correct.");
return;
}
string path = customPath.Text;
parent.addFile(path, fileTextbox.Text, this);
}
}
private void browse_Click(object sender, EventArgs e)
{
if (Check())
{
string file = customPath.Text.Substring(customPath.Text.LastIndexOf("/") + 1);
fileDialog.Filter = file + " file|" + file;
if (fileDialog.ShowDialog() == DialogResult.OK)
{
fileTextbox.Text = fileDialog.FileName;
}
}
}
}
}