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

推荐订阅源

月光博客
月光博客
Microsoft Security Blog
Microsoft Security Blog
T
Threatpost
D
DataBreaches.Net
B
Blog RSS Feed
GbyAI
GbyAI
T
The Blog of Author Tim Ferriss
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
N
Netflix TechBlog - Medium
O
OpenAI News
Webroot Blog
Webroot Blog
Stack Overflow Blog
Stack Overflow Blog
Recent Announcements
Recent Announcements
Google Online Security Blog
Google Online Security Blog
SecWiki News
SecWiki News
H
Help Net Security
Forbes - Security
Forbes - Security
N
News and Events Feed by Topic
aimingoo的专栏
aimingoo的专栏
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
腾讯CDC
B
Blog
H
Heimdal Security Blog
博客园 - 三生石上(FineUI控件)
C
CERT Recently Published Vulnerability Notes
L
Lohrmann on Cybersecurity
G
Google Developers Blog
Scott Helme
Scott Helme
C
CXSECURITY Database RSS Feed - CXSecurity.com
罗磊的独立博客
V
Visual Studio Blog
L
LINUX DO - 热门话题
T
Threat Research - Cisco Blogs
T
The Exploit Database - CXSecurity.com
F
Full Disclosure
C
Cisco Blogs
The Last Watchdog
The Last Watchdog
Security Archives - TechRepublic
Security Archives - TechRepublic
F
Fortinet All Blogs
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Google DeepMind News
Google DeepMind News
S
Security Affairs
P
Privacy & Cybersecurity Law Blog
S
Secure Thoughts
V
V2EX
雷峰网
雷峰网
Security Latest
Security Latest
H
Hacker News: Front Page
TaoSecurity Blog
TaoSecurity Blog
M
MIT News - Artificial intelligence

博客园 - 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)  评论()    收藏  举报