Hallo liebes Forum...
ich habe eine Funktion, die mir ein ListView wie folgt füllt:
Ich möchte die Funktion gern so erweitern, dass die Dateien nach Erstelldatum aufsteigend, also die älteste Datei als letztes, sortiert werden.
Hat jemand eine Idee, wie das möglich ist? Oder gibt es dafür mittlerweile was fertiges?
Hier der Code:
Vielen Dank schon mal...
Fragen ins Forum; Tipps & Tutorials in "Tipps & Tutorials". Ganz einfach, wirklich! Verschoben. ~fufu
ich habe eine Funktion, die mir ein ListView wie folgt füllt:
Ich möchte die Funktion gern so erweitern, dass die Dateien nach Erstelldatum aufsteigend, also die älteste Datei als letztes, sortiert werden.
Hat jemand eine Idee, wie das möglich ist? Oder gibt es dafür mittlerweile was fertiges?
Hier der Code:
VB.NET-Quellcode
- Public Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
- Dim parts() As String = Split(My.User.Name, "\")
- Dim username As String = parts(1)
- lblUser.Text = "Angemeldet als " & username
- ListView1.LargeImageList = ImageList1
- ListView1.SmallImageList = ImageList1
- ListView1.View = System.Windows.Forms.View.List
- Dim SuchPfad As String
- Dim dirInfo As DirectoryInfo
- Dim fileInfo As FileInfo
- Dim exeIcon As System.Drawing.Icon
- SuchPfad = "C:\Test\Daten"
- dirInfo = New DirectoryInfo(SuchPfad)
- LabelOrdner.Text = SuchPfad
- For Each fileInfo In dirInfo.GetFiles
- If (Not String.IsNullOrEmpty(fileInfo.Extension)) Then
- exeIcon = System.Drawing.Icon.ExtractAssociatedIcon(fileInfo.FullName)
- If (ImageList1.Images.ContainsKey(fileInfo.FullName)) Then
- ListView1.Items.Add(fileInfo.Name, fileInfo.FullName)
- ElseIf (Not exeIcon Is Nothing) Then
- ImageList1.Images.Add(fileInfo.FullName, exeIcon)
- With ListView1.Items.Add(fileInfo.Name, fileInfo.FullName)
- End With
- Else
- ListView1.Items.Add(fileInfo.Name)
- End If
- End If
- Next
- End Sub
- Public Function GetAssociatedProgram(ByVal FileExtension As _
- String) As String
- ' Returns the application associated with the specified
- ' FileExtension
- ' ie, path\denenv.exe for "VB" files
- Dim objExtReg As Microsoft.Win32.RegistryKey = _
- Microsoft.Win32.Registry.ClassesRoot
- Dim objAppReg As Microsoft.Win32.RegistryKey = _
- Microsoft.Win32.Registry.ClassesRoot
- Dim strExtValue As String
- Try
- ' Add trailing period if doesn't exist
- If FileExtension.Substring(0, 1) <> "." Then _
- FileExtension = "." & FileExtension
- ' Open registry areas containing launching app details
- objExtReg = objExtReg.OpenSubKey(FileExtension.Trim)
- strExtValue = objExtReg.GetValue("").ToString
- objAppReg = objAppReg.OpenSubKey(strExtValue & _
- "\shell\open\command")
- ' Parse out, tidy up and return result
- Dim SplitArray() As String
- SplitArray = Split(objAppReg.GetValue(Nothing).ToString, """")
- If SplitArray(0).Trim.Length > 0 Then
- Return SplitArray(0).Replace("%1", "")
- Else
- Return SplitArray(1).Replace("%1", "")
- End If
- Catch
- Return ""
- End Try
- End Function
Vielen Dank schon mal...
Fragen ins Forum; Tipps & Tutorials in "Tipps & Tutorials". Ganz einfach, wirklich! Verschoben. ~fufu
Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von „fufu“ ()