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

推荐订阅源

云风的 BLOG
云风的 BLOG
Hacker News: Ask HN
Hacker News: Ask HN
C
CXSECURITY Database RSS Feed - CXSecurity.com
T
The Exploit Database - CXSecurity.com
The Hacker News
The Hacker News
Security Latest
Security Latest
Attack and Defense Labs
Attack and Defense Labs
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Scott Helme
Scott Helme
H
Heimdal Security Blog
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
WordPress大学
WordPress大学
雷峰网
雷峰网
L
LangChain Blog
Y
Y Combinator Blog
I
Intezer
V
Vulnerabilities – Threatpost
Apple Machine Learning Research
Apple Machine Learning Research
The Last Watchdog
The Last Watchdog
Simon Willison's Weblog
Simon Willison's Weblog
W
WeLiveSecurity
P
Privacy International News Feed
V
Visual Studio Blog
T
The Blog of Author Tim Ferriss
A
About on SuperTechFans
AI
AI
博客园 - Franky
Hacker News - Newest:
Hacker News - Newest: "LLM"
Martin Fowler
Martin Fowler
K
Kaspersky official blog
U
Unit 42
S
Schneier on Security
Webroot Blog
Webroot Blog
Know Your Adversary
Know Your Adversary
T
Tor Project blog
aimingoo的专栏
aimingoo的专栏
Engineering at Meta
Engineering at Meta
G
GRAHAM CLULEY
美团技术团队
TaoSecurity Blog
TaoSecurity Blog
C
Cybersecurity and Infrastructure Security Agency CISA
Google DeepMind News
Google DeepMind News
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Jina AI
Jina AI
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
人人都是产品经理
人人都是产品经理
P
Proofpoint News Feed
爱范儿
爱范儿
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)  评论()    收藏  举报