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

推荐订阅源

雷峰网
雷峰网
月光博客
月光博客
S
Security Affairs
宝玉的分享
宝玉的分享
D
DataBreaches.Net
MongoDB | Blog
MongoDB | Blog
Cloudbric
Cloudbric
PCI Perspectives
PCI Perspectives
B
Blog RSS Feed
腾讯CDC
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Attack and Defense Labs
Attack and Defense Labs
N
News and Events Feed by Topic
T
The Blog of Author Tim Ferriss
H
Help Net Security
Vercel News
Vercel News
W
WeLiveSecurity
U
Unit 42
S
SegmentFault 最新的问题
Microsoft Azure Blog
Microsoft Azure Blog
Google Online Security Blog
Google Online Security Blog
云风的 BLOG
云风的 BLOG
Google DeepMind News
Google DeepMind News
S
Schneier on Security
The Register - Security
The Register - Security
酷 壳 – CoolShell
酷 壳 – CoolShell
Recent Announcements
Recent Announcements
博客园 - Franky
H
Hacker News: Front Page
WordPress大学
WordPress大学
I
Intezer
M
MIT News - Artificial intelligence
博客园 - 叶小钗
The Last Watchdog
The Last Watchdog
T
Troy Hunt's Blog
Stack Overflow Blog
Stack Overflow Blog
Microsoft Security Blog
Microsoft Security Blog
L
Lohrmann on Cybersecurity
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
I
InfoQ
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Schneier on Security
Schneier on Security
P
Proofpoint News Feed
V
V2EX
Help Net Security
Help Net Security
小众软件
小众软件
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
大猫的无限游戏
大猫的无限游戏
The GitHub Blog
The GitHub Blog
F
Fortinet All Blogs

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