• C# 遍历指定目录下的所有文件及文件夹以及遍历数据库的方法


    // DirectoryInfo di = new DirectoryInfo(@"D:Test");
    // FindFile(di); 
    static void FindFile(DirectoryInfo di)
    {
      FileInfo[] fis = di.GetFiles();
      for (int i = 0; i < fis.Length; i++)
      {
        Console.WriteLine("文件:" + fis[i].FullName);
      }
      DirectoryInfo[] dis = di.GetDirectories();
      for (int j = 0; j < dis.Length; j++)
      {
        Console.WriteLine("目录:" + dis[j].FullName);
        FindFile(dis[j]);
      }
    }

    根据父级遍历全部数据

           BaseOrganizeManager organizeManager = new BaseOrganizeManager();
            int count = 0;
            JsonResult<string> reult = null;
            void FindChild(List<BaseOrganizeEntity> organizeEntities)
            {
                foreach (var item in organizeEntities)
                {
                    if (item.Enabled == 0 || item.DeletionStateCode == 1)
                    {
                        continue;
                    }
                    reult = CaiNiaoAPIUtilities.SyncOrganizeToCaiNiao(item);
                    System.Console.WriteLine(count + ",执行同步:" + item.FullName + "," + DateTime.Now);
                    System.Console.WriteLine("返回" + reult.Data + "," + DateTime.Now);
                    count++;
    
                }
                List<BaseOrganizeEntity> organizeChids = null;
                string where = string.Empty;
                foreach (var item in organizeEntities)
                {
                    where = BaseOrganizeEntity.FieldParentId + " = '" + item.Id + "' ";
                    organizeChids = organizeManager.GetList<BaseOrganizeEntity>(where);
                    FindChild(organizeChids);
                }
            }
                string where = BaseOrganizeEntity.FieldParentId + " IS NULL ";
                List<BaseOrganizeEntity> organizeEntities = organizeManager.GetList<BaseOrganizeEntity>(where);
                FindChild(organizeEntities);
  • 相关阅读:
    数组定义和使用
    跳转语句—break,continue,goto
    案例 天线抬不起头来
    int是几位;short是几位;long是几位 负数怎么表示
    Python3的类注意事项
    用usb线配置直流电机驱动器不能配置成功
    案例 电源灯亮,但是就是不闪灯,而且也下载不了程序
    关于ai算法的一个点子
    进程 并发 线程 032
    ftp功能深度剖析 + 线程 031
  • 原文地址:https://www.cnblogs.com/hnsongbiao/p/8401052.html
Copyright © 2020-2023  润新知