-
Notifications
You must be signed in to change notification settings - Fork 1
/
SystemMap.cs
95 lines (81 loc) · 2.66 KB
/
SystemMap.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
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace Microsoft.Samples.Kinect.ColorBasics
{
class SystemMap
{
private String winDir = System.Environment.GetEnvironmentVariable("windir");
private List<String> f = new List<String>();
private void addListItem(String value) {
this.f.Add(value);
}
public List<String> getSubContent(String path){
String[] directories = null;
String[] files = null;
List<String> content = new List<String>();
if (!path.Contains("."))
{
try
{
directories = Directory.GetDirectories(path);
files = Directory.GetFiles(path);
foreach (String directory in directories)
{
string[] pathFragments = directory.Split('\\');
String name = pathFragments.Last() + '\\';
content.Add(name);
}
foreach (String file in files)
{
string[] pathFragments = file.Split('\\');
String name = pathFragments.Last();
content.Add(name);
}
}
catch (IOException ex)
{
Console.WriteLine(ex.Message);
return content;
}
catch (System.UnauthorizedAccessException ex)
{
Console.WriteLine(ex.Message);
return content;
}
}
else
{
//content.Add("NOT FOUND");
}
/*else if (File.Exists(path))
{
files = Directory.GetFiles(path);
foreach (String file in files)
{
string[] pathFragments = file.Split('\\');
String name = pathFragments.Last();
content.Add(name);
}
}*/
return content;
}
public SystemMap(){
string[] drives = Directory.GetLogicalDrives();
foreach (String drive in drives)
{
addListItem(drive);
}
}
public List<String> getLocals()
{
List<String> sss = new List<String>();
foreach(String fi in f){
sss.Add(fi);
}
return sss;
}
}
}