あにす #4482(2007/11/29 14:04 GMT) [ C# ] Rating0/0=0.00
System.Windows.FormsのTreeViewに表示させてみました。
see: 貧脚レーサーのサボり日記
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
//http://ja.doukaku.org/ //http://ja.doukaku.org/102/投稿用 using System; using System.Windows.Forms; namespace どう書く_orgフォルダパス一覧のツリー構造への変換 { class Program { [STAThread] static void Main(string[] args) { Application.Run(new Form1()); } } class Form1:Form { //treeView1 TreeView treeView1 = new TreeView(); //起動時引数でパス一覧のファイルを指定 string pathListFilePath = System.Environment.GetCommandLineArgs()[1]; public Form1() { //Form1 this.Load += new EventHandler(Form1_Load); //treeView1 treeView1.Parent = this; treeView1.Dock = DockStyle.Fill; } void Form1_Load(object sender, EventArgs e) { //ROOTNode TreeNode rootNode = new TreeNode("ROOT"); treeView1.Nodes.Add(rootNode); foreach(string fullPath in System.IO.File.ReadAllLines(pathListFilePath)) { TreeNode addNode = rootNode; foreach(string path in fullPath.Split(new char[] { '\\' })) { bool flag = true; foreach(TreeNode node in addNode.Nodes) { if(node.Text == path) { addNode = node; flag = false; } } if(flag) { TreeNode newnode = new TreeNode(path); addNode.Nodes.Add(newnode); addNode = newnode; } } } rootNode.ExpandAll(); } } }
Rating0/0=0.00-0+
[ reply ]
あにす
#4482()
[
C#
]
Rating0/0=0.00
System.Windows.FormsのTreeViewに表示させてみました。
see: 貧脚レーサーのサボり日記
Rating0/0=0.00-0+
[ reply ]