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)
  • 相关阅读:
    修改 PHP 最大运行时间 max_execution_time
    去除桌面的不可清理的恶意图标
    SQL 性能调优 set statistics io
    SQL Server 2008 Failover Cluster
    [转]SQLSERVER数据存储内幕
    博客开通
    Entity FrameWork 4.3 实体属性为decimal时默认只保存2位小数
    FreeBSD常用命令及配置
    动态加载JS或CSS
    JS获取传入该页面的参数
  • 原文地址:https://www.cnblogs.com/XiaoLang0/p/12133816.html
Copyright © 2011-2022 走看看