- 浏览: 348640 次
- 性别:
- 来自: 广州
文章分类
最新评论
-
tianshawang:
楼主你好偏心啊,把代码给谷歌不给这里
java 实现windows资源管理器 -
tianshawang:
其实我是也想要资源管理器的代码来的。。
java 实现windows资源管理器 -
hcmfys:
lonuery 写道open file 是获取要进行复制的文件 ...
JAVA 复制 带进度条 时间 百分比 -
qq657052171:
怎么没有代码呢?
java 实现windows资源管理器 -
IT女民工:
楼主,求资源管理器代码~~~~
java 实现windows资源管理器
用法DOS 命令 发现 Tree 命令很有趣 就用C# 写了一个
写得不好请指教
http://files.cnblogs.com/hcmfys/code.rar
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
namespace com.qiuSmile
{
public class FileTree
{
/// <summary>
/// 此程序是模仿DOS tree功能
/// 作者 相思雨 hcmfys@163.com
/// 2008-09-14 中秋节
// 使用方法
// FileTree.showTree("c:\\");
//如果要显示文件 FileTree.showFile=true;
// 如果要写入文件则加上 FileTree.writeFile("d:\\test.txt");
/// our knowlege belong to all human
/// </summary>
private static int nodeCount = 1;
private static bool first = false;
private static DirectoryInfo root = null;
private static string splitString = "├─";
private static string empty = " ";
private static string insertString = "│";
private static string fileStr = "";
public static bool showFile = false;// show file name
public static void showTree(string dir)
{
try
{
string str = "";
StringBuilder strBulider = new StringBuilder();
DirectoryInfo dirDirctory = new DirectoryInfo(dir);
if (!first)
{
root = new DirectoryInfo(dir);
first = true;
}
DirectoryInfo[] sonDir = dirDirctory.GetDirectories();
int len = sonDir.Length;
for (int i = 0; i <= len - 1; i++)
{
str = "";
nodeCount = getFatherCount(sonDir[i], root);
for (int k = 0; k < nodeCount; k++)
{
str += empty;
}
str += str + splitString + sonDir[i].Name;
if (!sonDir[i].Parent.FullName.Equals(root.FullName))
{
if (nodeCount != 0)
{
string tmpStr = "";
for (int j = 0; j < nodeCount; j++)
{
int index = -1;
tmpStr += empty;
index = tmpStr.Length;
if (j == 0) index = 0;
if (j > 1) index = index + (j - 1) * 2;
str = str.Insert(index, insertString);
str = str.Remove(index + insertString.Length, insertString.Length);
}
}
}
Console.WriteLine(str);
fileStr += str + "\n";
showTree(sonDir[i].FullName);
}
if (showFile)
{
FileInfo[] fSonDir = dirDirctory.GetFiles();
len = fSonDir.Length;
for (int i = 0; i <= len - 1; i++)
{
str = "";
nodeCount = getFatherCount(fSonDir[i].Directory, root);
for (int k = 0; k < nodeCount; k++)
{
str += empty;
}
str += str + splitString +"> "+ fSonDir[i].Name;
if (!fSonDir[i].Directory.FullName.Equals(root.FullName))
{
if (nodeCount != 0)
{
string tmpStr = "";
for (int j = 0; j < nodeCount; j++)
{
int index = -1;
tmpStr += empty;
index = tmpStr.Length;
if (j == 0) index = 0;
if (j > 1) index = index + (j - 1) * 2;
str = str.Insert(index, insertString);
str = str.Remove(index + insertString.Length, insertString.Length);
}
}
}
Console.WriteLine(str);
fileStr += str + "\n";
}
}
}
catch (Exception) { }
}
/// <summary>
/// 获取父节点的数目
/// </summary>
/// <param name="myInfo"></param>
/// <param name="root"></param>
/// <returns></returns>
private static int getFatherCount(DirectoryInfo myInfo, DirectoryInfo root)
{
int i = 0;
DirectoryInfo father = myInfo.Parent;
while (father != null && !father.FullName.Equals(root.FullName))
{
father = father.Parent;
i++;
}
return i;
}
public static void writeFile(string fileName)
{
File.WriteAllText(fileName, fileStr);
}
/// <summary>
/// test main method
/// </summary>
public static void test()
{
Console.ForegroundColor = ConsoleColor.White;
Console.BackgroundColor = ConsoleColor.Black;
Console.Title = "c# dos Tree";
Console.WriteLine("请你输入要显示的目录");
string inputString = Console.ReadLine();
//FileTree.showFile = true;
if (inputString.Trim().Length > 0)
{
showTree(inputString);
}
writeFile("d:\\12.txt");
Console.WriteLine("按任意键退出.....");
Console.Read();
}
}
}
发表评论
-
单线程 文件查找
2010-02-06 17:14 834using System; using System.Col ... -
多线程 多线程文件查找
2010-02-06 17:13 1173using System; using System.Col ... -
c# 生成小图
2008-05-22 11:39 937/// <summary> /// ... -
c#.net常用函数和方法集
2008-05-27 11:43 770、DateTime 数字型 System.DateTime ... -
FTPFactory.cs
2008-06-12 09:27 1064using System; using System. ... -
ASP.net防止SQL注入方法
2008-07-11 15:22 8731、sql注入比较难防,需 ... -
ASP.Net中自定义Http处理及应用之HttpModule篇 (转载)
2008-09-17 16:14 969HttpHandler实现了类似于ISAPI Extenti ... -
代码格式化 JAVA c# CodeFormat
2008-11-11 17:50 1035using System; using System.Coll ... -
c++ point
2009-05-06 12:15 1105介绍 曾碰到过让您迷 ... -
c# 屏幕截屏工具
2009-09-03 16:19 2278最近没事,开发了个截屏工具 模仿qq截屏功能!!下载地址 / ... -
C# 版芊芊静听
2009-09-11 15:05 841/Files/hcmfys/csttplayer.rar -
C# BCD编码解码
2010-01-13 15:21 3236(1)BCD码(二到十进制编码) 人们通常习惯使用十进制数,而 ... -
chm
2009-12-24 09:10 1104经常碰到一些 CHM 格 ... -
mapInfo
2009-12-04 17:57 815mapINfo 2005 -
Asp.Net中Excel操作权限的问题
2009-12-03 20:58 1691原创 Asp.Net中Excel操作权限的问题 收藏 提 ... -
How to configure Office applications to run under the interactive user account
2009-12-03 20:48 3736We do not recommend or support ... -
c# 操作Excel 权限问题
2009-12-03 20:46 3885Web.config上添加了“<identity i ... -
C#操作excel sheet
2009-12-01 20:58 3308C#操作excel sheet 这里有个VB.NET利用数 ... -
C# 对Excel表格的操作
2009-12-01 20:52 1581using Excel; using System.Refl ...
相关推荐
C# Winform Tree 使用示例,涉及子节点新增、编辑、删除、升级、降级、排序等功能
C# Tree实验Tree实验 Tree实验 Tree实验 Tree实验 Tree实验 Tree实验 Tree实验
懂的人自然懂:) 用C#写的binarytree
c#TREE非常优秀的源码c#TREE非常优秀的源码c#TREE非常优秀的源码c#TREE非常优秀的源码c#TREE非常优秀的源码c#TREE非常优秀的源码
asp.net(c#) tree 控件动态绑定数据
用c#执行dos命令,dos命令输入框在屏幕右下角,执行的内容显示在桌面上,里面包含dos命令运行函数以及按键控制。
本代码演示通过执行DOS命令并返回结果。 特点1:支持启动子进程 特点2:解决由于命令或者子进程阻塞的情况 特点3:可关闭子进程 特点4:设置命令或进程默认超时时间
c# winfrom 鼠标拖动panel
c#使用HtmlParser建立文档树 DomTree By Tk
实时获取DOS的输出结果,显示在C#窗口中。 为了避免阻塞主线程,把执行过程放在一个新的Thread中,防止了DOS执行中,C#窗口“假死”现象。 网上有个管道实现DOS输出的程序,没看懂,也不能编译,却被各网站,很多...
C#调用DOS命令方法
本程序采用VS2010软件开发,用的是C#语言,提供源码,主要功能如下 1, 可持续ping 1个IP地址或多个IP地址,可选择记录在指定的文件或自动生成文件记录或不记录。可查看IP什么时候丢包。保存的文件的路径也会做相应...
C#模拟Dos命令的一个程序,免费资源。希望大家喜欢、
C#实现Huffman算法,可以对字母进行编码,呵呵
c#执行DOS命令 1:设定需要执行的命令 2:表示执行完命令后马上退出 3:可以重定向输出
C#执行Dos命令项目源代码,使用多线程技术,采用异步读取窗口返回信息,效果不错。
C#中运行DOS命令并且隐藏DOS界面 此文件代码 演示了如何在C#中执行DOS命令 (并且不显示DOS窗体!!!!) 绝对精华,原来看到有人问这个,今天我给发出啦!
FPtree的java和C#的代码实现,是Aprior算法的改进版本,对于关联规则挖掘可以看看
C# TrieTree介绍及实现方法,需要的朋友可以参考一下
C# DOS 命令行方式实现Apriori算法.zip