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

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
H
Hacker News: Front Page
P
Palo Alto Networks Blog
T
ThreatConnect
Apple Machine Learning Research
Apple Machine Learning Research
博客园_首页
T
True Tiger Recordings
P
Privacy & Cybersecurity Law Blog
B
Blog
IT之家
IT之家
Last Week in AI
Last Week in AI
F
Full Disclosure
Hacker News: Ask HN
Hacker News: Ask HN
C
Comments on: Blog
Microsoft Azure Blog
Microsoft Azure Blog
C
Cybersecurity and Infrastructure Security Agency CISA
Microsoft Security Blog
Microsoft Security Blog
博客园 - 【当耐特】
N
News and Events Feed by Topic
NISL@THU
NISL@THU
腾讯CDC
雷峰网
雷峰网
Security Latest
Security Latest
李成银的技术随笔
M
Microsoft Research Blog - Microsoft Research
L
LangChain Blog
L
Lohrmann on Cybersecurity
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
Check Point Blog
Y
Y Combinator Blog
Recent Announcements
Recent Announcements
博客园 - Franky
N
News | PayPal Newsroom
V
V2EX
A
About on SuperTechFans
The Register - Security
The Register - Security
月光博客
月光博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google Online Security Blog
Google Online Security Blog
MyScale Blog
MyScale Blog
Cisco Talos Blog
Cisco Talos Blog
Vercel News
Vercel News
WordPress大学
WordPress大学
C
Cyber Attacks, Cyber Crime and Cyber Security
The Hacker News
The Hacker News
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
爱范儿
爱范儿
A
Arctic Wolf
L
LINUX DO - 最新话题
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

博客园 - flashicp

一个购物分享网站核心源码分析 ECSHOP读写分离配置与改造(转载) - flashicp 多年没有管理的技术博客了,即日起开始管理起技术博客 Apache里的 MPM 调优比较详细 c# WebBrowser网页操作-元素获取_事件操作 - flashicp zend framework多模块多布局配置 c# office不同版本下中使用Excel - flashicp 中秋 国庆 最近在忙项目,好久不来 转 :如何提高自己的编程水平 衣物去污指南 转 洗衣小窍门集锦 牙膏的妙用 转 家居小窍门 (二) 转 家居小窍门 (一) 转 --有些事情需要注意 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  阅读(455)  评论()    收藏  举报