01
Jun

بسبب خسارتي لبياناتي اكثر من مرة رأيت ان مشاركة ملفاتي الموجودة علي القرص الصلب أمراً صائبا لان ما كنت اشاركه هو الشيء المتبقي لذا ربما ستجدون مقالات من هذا النوع ومنها هذا المقال و الذي يحتوي علي كلاس فكرته موجوده في كتاب البرمجة الشيئية الذي امتحنت فيه قبل ايام.

الكلاس مكتوبة ب VB.Net و تبحث عن عدد الملفات الموجود في مكان معين باستخدام تاريخ الملفات او حجمها او امتداتها و الكود يفسر نفسه

Class CountFiles
'// Get Files Number in Specific Folder - License: Public Domain
    Public Overloads Function GetFiles(ByVal Max As Integer, ByVal Min As Integer, ByVal PATH As String) As Integer
        Max = Max * 1024 * 1024 'To Convert MB to Byte
        Min = Min * 1024 * 1024 'To Convert MB to Byte
        Dim files() As String
        files = System.IO.Directory.GetFiles(PATH)
        Dim i, counter As Integer
        For i = 0 To UBound(files)
            Dim F1 As New System.IO.FileInfo(files(i))
            If F1.Length < Max And F1.Length > Min Then
                counter += 1
            End If
        Next
        Return (counter)
    End Function
    Public Overloads Function GetFiles(ByVal toDate As Date, ByVal FromDate As Date, ByVal PATH As String) As Integer
        'To Get Files Nuumber By Date
        Dim files() As String
        files = System.IO.Directory.GetFiles(PATH)
        Dim i, counter As Integer
        For i = 0 To UBound(files)
            Dim F1 As New System.IO.FileInfo(files(i))
            If F1.CreationTime.Date < toDate And F1.CreationTime.Date > FromDate Then
                counter += 1
            End If
        Next
        Return (counter)
    End Function
    Public Overloads Function GetFiles(ByVal ext As String, ByVal PATH As String) As Integer
        'To Get Files Nuumber By Extention
        Dim files() As String
        files = System.IO.Directory.GetFiles(PATH, "*." + ext)
        Dim i, counter As Integer
        For i = 0 To UBound(files)
            counter += 1
        Next
        Return (counter)
    End Function
End Class

للتاكد من عمل الكلاس
اكتب الكود الأتي في اي زر

Dim DllFiles As New CountFiles()
MsgBox(DllFiles.GetFiles("dll", "c:/windows"))

سيأتي لك بعدد الملفات ذات الأمتداد DLL في المجلد c:/windows
ارجو ان يستفاد شخص ما من هذه الفئة

, , ,

2 تعليق على “Count My Files Class”

  • The previous system involved a cold call from someone representing one of these
    traditional advertising resources, who simple sold you an ad in their publication,
    the price you paid depended on the size of the ad, whether
    is was in colour or monochrome and how many publications your ad appeared in as companies such as the yellow pages had different publications
    covering different areas. When you shop at local stores and use locally-owned and run services,
    you not only help keep these businesses afloat, you
    support the local economy. Lim started part-time
    practice as a spirit medium in 1973.

  • Just wish to say your article is as surprising. The clearness in your post is just great and i can assume you’re
    an expert on this subject. Fine with your permission allow me to grab your
    RSS feed to keep up to date with forthcoming post.
    Thanks a million and please keep up the gratifying work.

اضافة تعليق