zoukankan      html  css  js  c++  java
  • 文件夹目录排序

    using System;
    using System.Collections.Generic;

    namespace Microsoft.Xna.User.GraphicsDeviceUserControl
    {
      public class FilesNameSort : IComparer<string>
      {
        [System.Runtime.InteropServices.DllImport("Shlwapi.dll", CharSet = System.Runtime.InteropServices.CharSet.Unicode)]
        public static extern int StrCmpLogicalW(string str1, string str2);
        public int Compare(string str1, string str2)
        {
          return StrCmpLogicalW(str1, str2);
        }
      }
      public partial class MyForm : Form
      {
        public MyForm()
        {
          InitializeComponent();
        }

        private void Button_Click(object sender, EventArgs e)
        {

          FolderBrowserDialog dialog = new FolderBrowserDialog();

          if (dialog.ShowDialog() == DialogResult.OK)
          {
            string strPath = dialog.SelectedPath;

            DirectoryInfo theFolder = new DirectoryInfo(strPath);

            FileInfo[] theFiles = theFolder.GetFiles("*.xnb");
            theFiles = theFiles.OrderBy(y => y.Name, new FilesNameSort()).ToArray();

            string[] files = new string[theFiles.Length];

            for (int i = 0; i < files.Count(); i++)
            {
              files[i] = Path.GetFileNameWithoutExtension(theFiles[i].FullName);
            }
          }
        }
      }
    }

    支持个人观看使用,如商用或转载,请告知! -----萧朗(QQ:453929789 Email:xiaolang_xl@sina.com)
  • 相关阅读:
    算法分析实验题集
    程序猿怎样解除烦恼
    MYSQL设计优化
    模式匹配KMP
    ios创建画笔的样例(双笔画效果)
    命令行解析器
    作业还是作孽?——Leo鉴书79
    客户机增加域 及server文件共享
    MySQL教程及经常使用命令1.1
    jsTree插件简介(三)
  • 原文地址:https://www.cnblogs.com/XiaoLang0/p/12133816.html
Copyright © 2011-2022 走看看