app to check for missing numerical files

swu

Active member
Joined
Mar 26, 2005
Messages
33
Programming Experience
1-3
I have alot of files that contain a numeric in their file name that is sequential.

i.e. file001.doc file002.doc, etc.

I would like to write a vb.net app to check the directory and list any files missing from the sequence.

I need help with what direction to start in.

Thanks in advance!

swu
 
VB.NET:
        Dim folderPath As String = "C:\MyFolder"
        Dim filePaths As String() = IO.Directory.GetFiles(folderPath)
        Dim fileName As String

        For i As Integer = 0 To 999
            fileName = String.Format("File{0:d3}.doc", i)

            If Array.IndexOf(filePaths, IO.Path.Combine(folderPath, fileName)) = -1 Then
                MessageBox.Show("File ""& filename &"" is missing.")
            End If
        Next i
or
VB.NET:
        Dim folderPath As String = "C:\MyFolder"
        Dim fileName As String

        For i As Integer = 0 To 999
            fileName = String.Format("File{0:d3}.doc", i)

            If Not IO.File.Exists(IO.Path.Combine(folderPath, fileName)) Then
                MessageBox.Show("File ""& filename &"" is missing.")
            End If
        Next i
 
Back
Top