Advertisement
Guest User

Untitled

a guest
Jun 24th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 1.70 KB | None | 0 0
  1. Friend Class Tree
  2.     Friend Root As Directory
  3.     Friend NumFiles As Integer
  4.     Friend NoDirectory As Boolean
  5. End Class
  6. Friend MustInherit Class FileObject
  7.     Protected m_list As New List(Of FileObject)
  8.     Private m_Name As String
  9.     Private m_FullName As String
  10.     Public Property Name As String
  11.         Get
  12.             Return m_name
  13.         End Get
  14.         Set(ByVal value As String)
  15.             m_name = value
  16.         End Set
  17.     End Property
  18.     Public Property FullName As String
  19.         Get
  20.             Return m_FullName
  21.         End Get
  22.         Set(ByVal value As String)
  23.             m_FullName = value
  24.         End Set
  25.     End Property
  26. End Class
  27. Friend Class File
  28.     Inherits FileObject
  29.     Private m_len As ULong
  30.     Public ReadOnly Property Len As ULong
  31.         Get
  32.             Return m_len
  33.         End Get
  34.     End Property
  35.     Public Sub New(ByVal FullName As String)
  36.         If IO.File.Exists(FullName) Then
  37.             Dim File As New IO.FileInfo(FullName)
  38.             Me.Name = File.Name
  39.             Me.FullName = FullName
  40.             m_len = File.Length
  41.         Else
  42.             Throw New Exception(FullName & " is not a file")
  43.         End If
  44.     End Sub
  45. End Class
  46. Friend Class Directory
  47.     Inherits FileObject
  48.     Public Sub New(ByVal FullName As String)
  49.         If IO.Directory.Exists(FullName) Then
  50.             Dim File As New IO.FileInfo(FullName)
  51.             Me.Name = File.Name
  52.             Me.FullName = FullName
  53.         Else
  54.             Throw New Exception(FullName & " is not a file")
  55.         End If
  56.     End Sub
  57.     Public ReadOnly Property Items As List(Of FileObject)
  58.         Get
  59.             Return m_list
  60.         End Get
  61.     End Property
  62. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement