• 大小: 346KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-06-10
  • 语言: 其他
  • 标签: 图片  视频  分类  

资源简介

手机和相机照片太多,手动按照片名称里的日期分成多个文件夹太麻烦,所以开发了这个小程序自动分类,不需要的请不要浪费分数下载。

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.Regularexpressions;
using System.Threading.Tasks;

namespace FilesManager
{
    public static class FilesHandler
    {

        ///   
        /// 获取路径下所有文件以及子文件夹中文件  
        /// 
  
        /// 全路径根目录  
        /// 存放所有文件的全路径  
        ///   
        public static List GetFile(string path List FileList)
        {
            DirectoryInfo dir = new DirectoryInfo(path);
            FileInfo[] fil = dir.GetFiles();
            DirectoryInfo[] dii = dir.GetDirectories();
            foreach (FileInfo f in fil)
                FileList.Add(f);
            //获取子文件夹内的文件列表,递归遍历  
            foreach (DirectoryInfo d in dii)
                GetFile(d.FullName FileList);
            return FileList;
        }

        public static string[] GetYMD(int startIndex string fileName)
        {
            string[] ymd = null;
            if (startIndex >= fileName.Length) return ymd;
            string date = ““;
            for(int i =0;i < fileName.Length; i++)
            {
                if(isNumberic(fileName[i].ToString()))
                {
                    if (date.Length < 8) date += fileName[i];
                }
            }
            if (date.Length == 8)
            {
                ymd = new string[] { ““ ““ ““ };
                ymd[0] = date.Substring(0 4);
                ymd[1] = date.Substring(4 2);
                ymd[2] = date.Substring(6 2);

                DateTime dateTime = new DateTime();
                bool convertResult = DateTime.TryParse(string.Join(“-“ ymd) out dateTime);
                if (!convertResult) return GetYMD(startIndex + 1 fileName);
                return ymd;
            }
            else return null;
        }


        public static bool isNumberic(string message)
        {
            Regex rex = new Regex(@“^\d+$“);
            if (rex.IsMatch(message))
                return true;
            else return false;
        }

        public static bool pathIsEq(string path1string path2)
        {
            string[] p1 = path1.Split(‘\\‘);
            string[] p2 = path2.Split(‘\\‘);
            if (p1.Length != p2.Length) return false;
            for (int i = 0; i < p1.Length; i++)
                if (p1[i] != p2[i]) return false;
            return true;
        }


    }
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

    ..A..H.     45056  2018-04-02 11:30  FilesManager\.vs\FilesManager\v14\.suo

     文件        189  2018-03-30 14:57  FilesManager\FilesManager\App.config

     文件        189  2018-03-30 14:57  FilesManager\FilesManager\bin\Debug\app.publish\Application Files\FilesManager_1_0_0_0\FilesManager.exe.config.deploy

     文件      13816  2018-04-02 11:26  FilesManager\FilesManager\bin\Debug\app.publish\Application Files\FilesManager_1_0_0_0\FilesManager.exe.deploy

     文件       7182  2018-04-02 11:26  FilesManager\FilesManager\bin\Debug\app.publish\Application Files\FilesManager_1_0_0_0\FilesManager.exe.manifest

     文件       5686  2018-04-02 11:26  FilesManager\FilesManager\bin\Debug\app.publish\FilesManager.application

     文件      13816  2018-04-02 11:26  FilesManager\FilesManager\bin\Debug\app.publish\FilesManager.exe

     文件     828920  2018-04-02 11:26  FilesManager\FilesManager\bin\Debug\app.publish\setup.exe

     文件       1843  2018-04-02 11:26  FilesManager\FilesManager\bin\Debug\FilesManager.application

     文件      12800  2018-04-02 11:26  FilesManager\FilesManager\bin\Debug\FilesManager.exe

     文件        189  2018-03-30 14:57  FilesManager\FilesManager\bin\Debug\FilesManager.exe.config

     文件       3447  2018-04-02 11:26  FilesManager\FilesManager\bin\Debug\FilesManager.exe.manifest

     文件      26112  2018-04-02 11:26  FilesManager\FilesManager\bin\Debug\FilesManager.pdb

     文件      22696  2018-04-02 11:25  FilesManager\FilesManager\bin\Debug\FilesManager.vshost.exe

     文件        189  2018-03-30 14:57  FilesManager\FilesManager\bin\Debug\FilesManager.vshost.exe.config

     文件        490  2015-10-22 09:54  FilesManager\FilesManager\bin\Debug\FilesManager.vshost.exe.manifest

     文件      13304  2018-04-02 11:30  FilesManager\FilesManager\bin\Release\app.publish\FilesManager.exe

     文件       1843  2018-04-02 11:30  FilesManager\FilesManager\bin\Release\FilesManager.application

     文件      12288  2018-04-02 11:30  FilesManager\FilesManager\bin\Release\FilesManager.exe

     文件        189  2018-03-30 14:57  FilesManager\FilesManager\bin\Release\FilesManager.exe.config

     文件       3447  2018-04-02 11:30  FilesManager\FilesManager\bin\Release\FilesManager.exe.manifest

     文件      26112  2018-04-02 11:30  FilesManager\FilesManager\bin\Release\FilesManager.pdb

     文件       1843  2018-04-02 11:30  FilesManager\FilesManager\bin\Release\FilesManager.vshost.application

     文件      22696  2018-04-02 11:30  FilesManager\FilesManager\bin\Release\FilesManager.vshost.exe

     文件        189  2018-03-30 14:57  FilesManager\FilesManager\bin\Release\FilesManager.vshost.exe.config

     文件       3447  2018-04-02 11:30  FilesManager\FilesManager\bin\Release\FilesManager.vshost.exe.manifest

     文件       2697  2018-04-02 10:09  FilesManager\FilesManager\FilesHandler.cs

     文件       5681  2018-04-02 11:27  FilesManager\FilesManager\FilesManager.csproj

     文件        453  2018-04-02 11:26  FilesManager\FilesManager\FilesManager.csproj.user

     文件       1716  2018-04-02 11:26  FilesManager\FilesManager\FilesManager_TemporaryKey.pfx

............此处省略59个文件信息

评论

共有 条评论