C# IO操作(五)文件的递归加载

本篇是一个案例,其核心通过代码展示代码中的递归这个用法,程序的界面如下:

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAyIAAAImCAIAAAAgyamrAAAgAElEQVR4nO3de7DfdX3n8e9f2253O+12s7Z1+kcnUwMu0BkJznS323YkVFdBvGQWRBREIRZRELkoF0PEtRFDbmoqSQhBAxEBoQoRcv+FhDsEciEkMSGEHJIQbh8SOp1Zwewfv3NOvr/fuSTv5HdA8n485j2Zk19+l5OzO/Kcl1qrvQAADIHq7f4GAAAOTzILAGBIyCwAgCEhswAAhoTMAgAYEtW55567d+9ev/rVr371q1/96le/dvZXaxYAwJDoXrPqjgMA4JBVbYF1/PHHz58/f9u2bW9h6gEAHIb2rVnHHXfc5MmTu7q6rrv7Seecc845d4i3b806/vjju7q6pt+9yjnnnHPOHfp1r1nHHXfc/Pnzp89b5ZxzzjnnOnJV779juG3bthm/Wu2cc8455zpy+9asf//3f595zxrnnHPOOdeR27dm7d27d9a9a51zzjnnXEdu35q1d+/eG+avdc4555xzHbmWNWv2gnXOOeecc64j17Jmve3fjXPOOed+B2/qrSu+PG76Zy/4bsfvy+OmT711RfNTpt+1cvwN9171L//a8Rt/w73T71rZ/JQb5y767N99dNSw4R2/z/7dR2+cu6j+c2tZs3688GnnnHPOubY759Ip85c/uWXn7o7f/OVPnnPplOan/N8Zd9+5bO19a7Z3/O5ctvb/zri7+SkfG/H+BTNmvr7msY7fghkzPzbi/fWfW8ua9ZNF6we6xgEb5E2cc8459068M796zZadu5ev3dHx27Jz95lfvab5KVf/6JfL1+6Y98jWjt/ytTuu/tEvm58yatjwPaseeeFn13f89qx6ZNSw4fWfW8uaNcjPt62fGo3GUze9u3mrfvznj17/pw9c964l3x8ms5x7C+7iE6vqqMsn7O857/nS/JYH//nUPq+af/pRLU/r51X7bsYHqved/uOetxpEz6f0933O+EBVfeCf+/x1aj7wzzM+0P/7nnrxovU/WbR+wpfe1+fj5p9+VMtjA/8tnHMHc5+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Qo1VrFkQJbMA0go1VrFmQZTMAkgr1FjFmgVRMgsgrVBjFWsWRMksgLTq/8q/dOnStn8W9H1krzULQmQWQFptUVXvqrbfHmRmNT9GZpGWzAJIq29mNdOq/vUhZZY1i+RkFkBabf/iv7RV33867LVmQYjMAkir77/+D9JYB5NZ1iySk1kAafUbNgM11sFkVvNjZBZpySyAtA6kc+r2WrMgRGYBpBVqrGLNgiiZBZBWqLGKNQuiZBZAWqHGKtYsiJJZAGmFGqtYsyBKZgFw4N6GNcu5d/T1m1nOOedcvxfIrENfswAAqOvYmgUAQJ01CwBgSFizAACGhDULAGBIWLMAAIaENQsAYEhYswAAhoQ1CwBgSFizAACGhDULAGBIWLMAAIZEP2vW/FW7nHPOOedcR65lzXrbvxvnnHPOucPm/j/vIAv6E6h47QAAAABJRU5ErkJggg==" alt="" />

当点击“加载”按钮时,根据路径中的地址,加载该文件夹下所有的子文件夹和子文件,代码如下:

 private void BtnLoad_Click(object sender, EventArgs e)
{
string sPath = txtPath.Text.Trim();
LoadDirAndFile(sPath, tvList.Nodes);
} private void LoadDirAndFile(string sPath, TreeNodeCollection treeNodeCollection)
{
string strDir = sPath.Substring(sPath.LastIndexOf(@"\") + );
TreeNode tNode = treeNodeCollection.Add(strDir); //加载所有目录
string[] strDir1 = Directory.GetDirectories(sPath);
foreach (string item in strDir1)
{
//返回目录的最后一级(名称)
string sDir = item.Substring(item.LastIndexOf(@"\") + );
TreeNode tNode1 = tNode.Nodes.Add(sDir);
LoadDirAndFile(item, tNode1.Nodes); //递归加载
} string[] strFiles = Directory.GetFiles(sPath, "*.txt");
foreach (string item in strFiles)
{
TreeNode tNodeFile = treeNodeCollection.Add(Path.GetFileName(item));
tNodeFile.Tag = item;
}
} private void tvList_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
{
if (e.Node.Tag!=null)
{
//文件节点
txtContent.Text = File.ReadAllText(e.Node.Tag.ToString(), Encoding.Default);
}
}

总结:

1.加载文件夹节点时,要考虑到文件夹下还有可能有子文件夹和子文件,所以要使用递归加载;

2.在实现点击文件节点,要在右边的文本框中查看文本文件全部的内容,就在递归加载文件夹和文件时,为所有的文件节点加了tag属性,后面双击节点时,只要tag属性不为空即为文件节点(读取即可),而为空的则是文件夹节点(不需要处理)。

上一篇:浅谈SQL中的单引号


下一篇:jQuery.validate API