I'm rewriting my app from a more classic Vb approach to a more OOP approach.
I got a class (in progress):
VB Code:
Public Class MyMovie Private strMovie As String Private strYear As String Private SubExtensions() As String = {".srt", ".sub"} Public Sub New(ByVal FullMovieName As String) strMovie = FullMovieName End Sub Public ReadOnly Property Name() As String Get Return My.Computer.FileSystem.GetFileInfo(strMovie).Name.ToString End Get End Property Public ReadOnly Property Folder() As String Get Return My.Computer.FileSystem.GetFileInfo(strMovie).Directory.FullName End Get End Property Public Property Year() As String Get Return strYear End Get Set(ByVal value As String) strYear = value End Set End Property Public ReadOnly Property Subs() As Boolean Get Return HasSubs() End Get End Property Private Function HasSubs() As Boolean Dim strExt As String Dim strMovieExt As String = strMovie.Trim.Substring((strMovie.Trim.Length) - 4, 4) Dim strSub As String = strMovie.Trim.Substring(0, (strMovie.Trim.Length) - 4) 'strip extension 'is there a file with the same name and a sub extension ? For Each strExt In SubExtensions If System.IO.File.Exists(strSub & strExt) Then Return True Exit Function End If Next Return False End Function End Class
Basicly I'm looping through a collection of files and depending on the extension Add an instance of my class to a Collection
VB Code:
Private colMovies As New Collection
VB Code:
(...) If booIsMovie Then If Not colMovies.Contains(strFile) Then 'Only add unique movies files to collection Dim newMovie As New MyMovie(strFile) colMovies.Add(newMovie, strFile) End If End If (...)
Thing is, the adding to the collection is rather slow. Also when I loop through
the collection (for testing) and show a message box with some info on each movie object, there's a noticably delay between closing a messagebox and the next one showing up.
Is this normal or Am I doing something wrong ?


Reply With Quote
