Public Shared Sub Parse(ByVal line As String) Dim protection As String = line.Substring(0, 10).Trim Dim owner As String = line.Substring(11, 19).Trim Dim size As Integer = Integer.Parse(line.Substring(32, 8).TrimEnd) Dim tim As String = line.Substring(40, 12).Trim Dim filename As String = line.Substring(53).Trim Console.WriteLine(filename & " " & size & " " & tim) End Sub
Public Shared Sub Main(ByVal args As String()) Parse("drwxr-xr-x 1 ftp ftp 0 Sep 01 19:38 Adobe Illustrator 10") Parse("drwxr-xr-x 1 ftp ftp 0 Sep 07 09:36 subdir") Parse("-rw-r--r-- 1 ftp ftp 1871872 Sep 07 11:52 a.zip") Parse("-rw-r--r-- 1 ftp ftp 21814474 Sep 07 09:53 z.zip") End Sub End Class
Class MainClass Public Shared Function Eater(ByVal line As String, ByVal ix As Integer, ByVal n As Integer) As String Dim res As String = "" Dim line2() As Char = line.ToCharArray Dim ws As Integer = 0 Dim i As Integer For i = 1 To (line2.Length - 1) If line2(i) = " " And line2(i-1) <> " " Then ws = ws + 1 End If If ws >= ix And ws < (ix + n) Then res = res & line2(i) End If Next Eater = res.Trim End Function
Public Shared Sub Parse(ByVal line As String) Dim protection As String = Eater(line, 0, 1) Dim owner As String = Eater(line, 1, 3) Dim size As Integer = Integer.Parse(Eater(line, 4, 1)) Dim tim As String = Eater(line, 5, 3) Dim filename As String = Eater(line, 8, 100) Console.WriteLine(filename & " " & size & " " & tim) End Sub
Public Shared Sub Main(ByVal args As String()) Parse("drwxr-xr-x 1 ftp ftp 0 Sep 01 19:38 Adobe Illustrator 10") Parse("drwxr-xr-x 1 ftp ftp 0 Sep 07 09:36 subdir") Parse("-rw-r--r-- 1 ftp ftp 1871872 Sep 07 11:52 a.zip") Parse("-rw-r--r-- 1 ftp ftp 21814474 Sep 07 09:53 z.zip") End Sub End Class
Mig der er en idiot... Dato og tid er i tim feltet...
sorry...
:)
Synes godt om
Ny brugerNybegynder
Din løsning...
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.