-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
50 lines (43 loc) · 1.6 KB
/
Program.cs
File metadata and controls
50 lines (43 loc) · 1.6 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
using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using DirectoryListing;
namespace DirectoryListing {
class Program {
static void Main(string[] args) {
//who the fuck knows what this shit is doing...
List<string> lstProcessData = new List<string>();
int nThreadCount=4;
ManualResetEvent[] doneEvents;
string dir = @"c:\music\";
getFileListing(dir, ref lstProcessData);
doneEvents = new ManualResetEvent[lstProcessData.Count()];
int i = 0;
foreach (string strDir in lstProcessData) {
doneEvents[i] = new ManualResetEvent(false);
WorkItem wkDir = new WorkItem(strDir, doneEvents[i]);
ThreadPool.SetMaxThreads(nThreadCount,nThreadCount);
ThreadPool.QueueUserWorkItem(wkDir.ThreadPoolCallback, i);
i++;
}
WaitHandle.WaitAll(doneEvents);
Console.WriteLine("All files Processed");
}
public static void getFileListing(string baseDir,ref List<string> lstDir) {
if (Directory.GetDirectories(baseDir).Count() != 0) {
foreach (string dirName in Directory.GetDirectories(baseDir)) {
getFileListing(dirName, ref lstDir);
lstDir.Add(dirName);
}
}
else {
lstDir.Add(baseDir);
}
}
}
}