|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Sort Directory.GetCurrentDirectory()How can I sort the contents of Directory.GetCurrentDirectory() by file create
data? If that is not possible how can I sort it by file name? Thanks! Bob "BobAchgill" <BobAchg***@discussions.microsoft.com> schrieb: \\\> How can I sort the contents of Directory.GetCurrentDirectory() by file > create > data? > > If that is not possible how can I sort it by file name? Public Class LastWriteTimeComparer Implements IComparer Public Function Compare( _ ByVal x As Object, _ ByVal y As Object _ ) As Integer Implements IComparer.Compare Return _ Math.Sign( _ File.GetLastWriteTime(DirectCast(x, String)).Ticks - _ File.GetLastWriteTime(DirectCast(y, String)).Ticks _ ) End Function End Class /// Usage: \\\ Dim FileNames() As String = Directory.GetFiles("C:\WINDOWS") Array.Sort(FileNames, New LastWriteTimeComparer()) Me.ListBox1.DataSource = FileNames /// Alternatively you may want to take a closer look at LINQ, which provides an ability to order the items. -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://dotnet.mvps.org/dotnet/faqs/> "BobAchgill" <BobAchg***@discussions.microsoft.com> wrote in message Directory.GetCurrentDirectory() returns a single string which is the name of news:017138AD-FE14-4779-8DFC-9DD3945BC0CC@microsoft.com... > How can I sort the contents of Directory.GetCurrentDirectory() by file > create > data? > > If that is not possible how can I sort it by file name? > > Thanks! > > Bob the current directory. Perhaps you should look at DirectoryInfo.GetFiles() or Directory.GetFiles(). DirectoryInfo.GetFiles() would give you the access to the CreateDate information to do the sort. -- Mike
Enable/Disable windows update
vb.net app not finding application configuration file on Windows 2003 Server Standard Not as 'explicit' as I thought --- What am I missing Formatting Text on a textbox Merging Bitmaps A question about a failing regular expression limiting combobox.... Pass Variable At Design Time What are the Versions of Visual Studio 2005 and what Features are Available in Each? Setting DataGridView.Height to Goldilocks value? |
|||||||||||||||||||||||