/
Trunk.aspx.cs
80 lines (63 loc) · 2.39 KB
/
Trunk.aspx.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
public partial class Trunk : BasePage
{
protected void Page_Load(object sender, EventArgs e)
{
if (Page.IsPostBack == false)
{
System.IO.DirectoryInfo RootDir = new System.IO.DirectoryInfo(@"D:\_ReleaseManagement\_Branches\DTS\Trunk\SRC");
// output the directory into a node
TreeNode RootNode = OutputDirectory(RootDir, null);
// add the output to the tree
TreeView1.Nodes.Add(RootNode);
TreeView1.CollapseAll();
TreeView1.SelectedNodeChanged+= new EventHandler(TreeView1_SelectedNodeChanged);
}
}
protected void TreeView1_SelectedNodeChanged(object sender, EventArgs e)
{
}
TreeNode OutputDirectory(System.IO.DirectoryInfo directory, TreeNode parentNode)
{
// validate param
if (directory == null) return null;
// create a node for this directory
TreeNode DirNode = new TreeNode(directory.Name);
// get subdirectories of the current directory
System.IO.DirectoryInfo[] SubDirectories = directory.GetDirectories();
// output each subdirectory
for (int DirectoryCount = 0; DirectoryCount < SubDirectories.Length; DirectoryCount++)
{
if(!SubDirectories[DirectoryCount].Extension.Contains(".svn"))
OutputDirectory(SubDirectories[DirectoryCount], DirNode);
}
// output the current directories files
System.IO.FileInfo[] Files = directory.GetFiles();
for (int FileCount = 0; FileCount < Files.Length; FileCount++)
{
if(Files[FileCount].Extension.EndsWith("cs") || Files[FileCount].Extension.EndsWith("sql"))
DirNode.ChildNodes.Add(new TreeNode(Files[FileCount].Name));
}
// if the parent node is null, return this node
// otherwise add this node to the parent and return the parent
if (parentNode == null)
{
return DirNode;
}
else
{
parentNode.ChildNodes.Add(DirNode);
return parentNode;
}
}
protected void TreeView1_SelectedNodeChanged1(object sender, EventArgs e)
{
ErrorMessage = TreeView1.SelectedNode.Text;
}
}