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

推荐订阅源

博客园 - 三生石上(FineUI控件)
Blog — PlanetScale
Blog — PlanetScale
B
Blog
GbyAI
GbyAI
爱范儿
爱范儿
月光博客
月光博客
N
Netflix TechBlog - Medium
T
Tailwind CSS Blog
G
Google Developers Blog
大猫的无限游戏
大猫的无限游戏
Vercel News
Vercel News
H
Hackread – Cybersecurity News, Data Breaches, AI and More
WordPress大学
WordPress大学
The GitHub Blog
The GitHub Blog
Recent Announcements
Recent Announcements
腾讯CDC
MyScale Blog
MyScale Blog
V
Visual Studio Blog
The Cloudflare Blog
Microsoft Security Blog
Microsoft Security Blog
A
About on SuperTechFans
Google DeepMind News
Google DeepMind News
Last Week in AI
Last Week in AI
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻

博客园 - zhengfeng

GridView 72般绝技 链接打开固定大小的新窗口 iframe传值和自适应高度 页面传参 小技巧 js表单验证控制代码大全 - zhengfeng - 博客园 自己写的递归方法复制文件夹里面的内容(从源文件(里面可以有多个层次的子文件夹)到一个文件夹) 递归写的复制文件夹及其下的内容(原样复制) JS取得URL中的参数值 使用 Hashtable 集合(一) MessageBox.Show用法 System.IO.File类和System.IO.FileInfo类 Math.floor和Math.ceil函数 Document对象 javascript小技巧 JavaScript的学习 正则表达式的学习: 工作小结: DataList分页
自己写的将文件从多个文件合并到一个文件夹的小方法
zhengfeng · 2007-07-20 · via 博客园 - zhengfeng

using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            Program manger = new Program();
            manger.CopyPicToFileDirectory("E:\\资讯抓取\\Images", "E:\\资讯抓取\\图片");
        }
        private void CopyPicToFileDirectory(string sourcePath, string desPath)
        {
         
                string[] dirs1 = null;
                string[] dirs2 = null;
                bool desFileDirectory = System.IO.Directory.Exists(desPath);
                if (desFileDirectory == false)
                {
                    Directory.CreateDirectory(desPath);
                }
                dirs1 = Directory.GetDirectories(sourcePath);
                for (int i = 0; i < dirs1.Length; i++)
                {
                    try
                    {
                        dirs2 = Directory.GetFiles(dirs1[i]);
                        for (int j = 0; j < dirs2.Length; j++)
                        {
                            FileInfo file = new FileInfo(dirs2[j]);
                            string filename = file.Name;
                            file.CopyTo(desPath + "\\" + filename, true);
                        }
                    }
                  catch (Exception ex)
                  {
                      Console.Write(ex.Message);
                      continue;
                  }
                }
          }
      

    }
}