using System;
using System.Collections.Generic;
namespace Microsoft.Xna.User.GraphicsDeviceUserControl
{
public class FilesNameSort : IComparer
{
[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);
}
}
}
}
}