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)
  • 相关阅读:
    python异常处理
    装饰器汇总
    PHP PDO预定义常量
    [转载]Firebird与MySQL:一个使用者的体会
    卸载AppDomain动态调用DLL异步线程执行失败
    c#数据库访问读取数据速度测试
    iis最大工作进程数
    WINCE 获取智能设备唯一编号
    通过 JDBC 驱动程序使用大容量复制
    IIS出现问题时修改配置文件的几项说明
  • 原文地址:https://www.cnblogs.com/XiaoLang0/p/12133816.html
Copyright © 2011-2022 走看看