惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

aimingoo的专栏
aimingoo的专栏
M
MIT News - Artificial intelligence
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
F
Fortinet All Blogs
L
LangChain Blog
D
Docker
G
Google Developers Blog
B
Blog RSS Feed
Google DeepMind News
Google DeepMind News
Vercel News
Vercel News
Recent Announcements
Recent Announcements
MyScale Blog
MyScale Blog
Microsoft Azure Blog
Microsoft Azure Blog
A
About on SuperTechFans
T
The Blog of Author Tim Ferriss
Recorded Future
Recorded Future
I
InfoQ
博客园 - 【当耐特】
The Cloudflare Blog
P
Proofpoint News Feed
GbyAI
GbyAI
博客园 - 司徒正美
U
Unit 42
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
IT之家
IT之家
H
Hackread – Cybersecurity News, Data Breaches, AI and More
B
Blog
Hugging Face - Blog
Hugging Face - Blog
博客园_首页
Stack Overflow Blog
Stack Overflow Blog
Microsoft Security Blog
Microsoft Security Blog
爱范儿
爱范儿
Jina AI
Jina AI
量子位
阮一峰的网络日志
阮一峰的网络日志
月光博客
月光博客
有赞技术团队
有赞技术团队
罗磊的独立博客
博客园 - 三生石上(FineUI控件)
Y
Y Combinator Blog
Apple Machine Learning Research
Apple Machine Learning Research
V
V2EX
大猫的无限游戏
大猫的无限游戏
F
Full Disclosure
雷峰网
雷峰网
美团技术团队
酷 壳 – CoolShell
酷 壳 – CoolShell
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
S
SegmentFault 最新的问题

博客园 - flashicp

一个购物分享网站核心源码分析 ECSHOP读写分离配置与改造(转载) - flashicp 多年没有管理的技术博客了,即日起开始管理起技术博客 Apache里的 MPM 调优比较详细 c# WebBrowser网页操作-元素获取_事件操作 zend framework多模块多布局配置 c# office不同版本下中使用Excel 中秋 国庆 最近在忙项目,好久不来 转 :如何提高自己的编程水平 衣物去污指南 转 洗衣小窍门集锦 牙膏的妙用 转 家居小窍门 (二) 转 家居小窍门 (一) 转 --有些事情需要注意 WinForm的App.config 保存我的操作日志 关于sql server表名 和字段的一点操作
目录下的文件 - flashicp - 博客园
flashicp · 2007-10-18 · via 博客园 - flashicp

目录下的文件

1、先帖一个 ArrayList循环的使用方式:
#region/***显示表格***/

  /// <summary>
  /// 循环ArrayList, 显示ArrayList中保存的内容
  /// </summary>
  /// <param name="arr"></param>
  /// <returns></returns>
  private void  GetOutDynamicTable(ArrayList arr)
  {
   try
   {

    if(arr!=null && arr.Count>0)
    {
     System.Collections.IEnumerator myEnumerator =arr.GetEnumerator();
     while (myEnumerator.MoveNext())
     {
      DynamicTable tempTable=(DynamicTable)myEnumerator.Current;

      MessageBox.Show(this,tempTable.ID+"\n"+tempTable.FileName+"\n"+tempTable.RelativePath+"\n"+tempTable.FullPath
       ,"显示表格",MessageBoxButtons.OK,MessageBoxIcon.Error);
     }
    }
    
   }
   catch (Exception err)
   {
    MessageBox.Show(this,err.Message,"显示表格",MessageBoxButtons.OK,MessageBoxIcon.Error);
   }
   
  }

  #endregion

 2、遍历目录就能获得文件个数
// 近来发现了一个效率更高的方法,只需遍历目录就能获得文件个数,现分享一下
  //    System.IO.DirectoryInfo dirInfo = new System.IO.DirectoryInfo(dirPath); 
  //
  //  public static int GetFilesCount(System.IO.DirectoryInfo dirInfo)
  //  {
  //   int totalFile = 0;
  //   totalFile += dirInfo.GetFiles().Length;
  //   foreach (System.IO.DirectoryInfo subdir in dirInfo.GetDirectories())
  //   {
  //    totalFile += GetFilesCount(subdir);
  //   }
  //   return totalFile;
  //  }

3、文件生成xml文档

#region

  //  /// <summary>
  //  /// 将指定目录下的子目录和文件生成xml文档
  //  /// </summary>
  //  /// <param name="targetDir">根目录</param>
  //  /// <returns>返回XmlDocument对象</returns>
  //  public static XmlDocument CreateXml(string targetDir)
  //  {
  //   XmlDocument myDocument = new XmlDocument();
  //   XmlDeclaration declaration = myDocument.CreateXmlDeclaration("1.0", "utf-8", null);
  //   myDocument.AppendChild(declaration);
  //   XmlElement rootElement = myDocument.CreateElement(targetDir.Substring(targetDir.LastIndexOf(PATH_SPLIT_CHAR) + 1));
  //   myDocument.AppendChild(rootElement);
  //   foreach (string fileName in Directory.GetFiles(targetDir))
  //   {
  //    XmlElement childElement = myDocument.CreateElement("File");
  //    childElement.InnerText = fileName.Substring(fileName.LastIndexOf(PATH_SPLIT_CHAR) + 1);
  //    rootElement.AppendChild(childElement);
  //   }
  //   foreach (string directory in Directory.GetDirectories(targetDir))
  //   {
  //    XmlElement childElement = myDocument.CreateElement("Directory");
  //    childElement.SetAttribute("Name", directory.Substring(directory.LastIndexOf(PATH_SPLIT_CHAR) + 1));
  //    rootElement.AppendChild(childElement);
  //    CreateBranch(directory, childElement, myDocument);
  //   }
  //   return myDocument;
  //  }

  #endregion


posted on 2007-10-18 16:00  flashicp  阅读(456)  评论()    收藏  举报