Link to home
Start Free TrialLog in
Avatar of gr8life
gr8life

asked on

Conditionally delete file




Good evening experts& I have a small application that builds 35 output files onload with headers. Before the application ends I want to basically delete the files that only contain the header and no other data.

Here is as close as I have been able to get.

Thank you very much for your time and expertise,
Gr8life

FYI: Im using 2003 vb.net.

Code:

    Public Sub noData(ByVal inFile, ByVal outFile1, ByVal outFile2, ByVal outFile3, ByVal outFile4, ByVal outFile5, ByVal outFile6, ByVal outFile7, ByVal outFile8, _
    ByVal outFile9, ByVal outFile10, ByVal outFile11, ByVal outFile12, ByVal outFile13, ByVal outFile14, ByVal outFile15, ByVal outFile16, _
    ByVal outFile17, ByVal outFile18, ByVal outFile19, ByVal outFile20, ByVal outFile21, ByVal outFile22, ByVal outFile23, _
    ByVal outFile24, ByVal outFile25, ByVal outFile26, ByVal outFile27, ByVal outFile28, ByVal outFile29, ByVal outFile30, ByVal outFile31, ByVal outFile32, _
    ByVal outFile33, ByVal outFile34, ByVal outFile35 As String)
        Dim FileToDelete As String

        If ((outFile1.Length = 1) And (outFile2.Length = 1) And (outFile3.Length = 1) And (outFile4.Length = 1) _
        And (outFile5.Length = 1) And (outFile6.Length = 1) And (outFile7.Length = 1) And (outFile8.Length = 1) _
        And (outFile9.Length = 1) And (outFile10.Length = 1) And (outFile11.Length = 1) And (outFile12.Length = 1) _
        And (outFile13.Length = 1) And (outFile14.Length = 1) And (outFile15.Length = 1) And (outFile16.Length = 1) _
        And (outFile17.Length = 1) And (outFile18.Length = 1) And (outFile19.Length = 1) And (outFile20.Length = 1) _
        And (outFile21.Length = 1) And (outFile22.Length = 1) And (outFile23.Length = 1) And (outFile24.Length = 1) _
        And (outFile25.Length = 1) And (outFile26.Length = 1) And (outFile27.Length = 1) And (outFile28.Length = 1) _
        And (outFile29.Length = 1) And (outFile30.Length = 1) And (outFile31.Length = 1) And (outFile32.Length = 1) _
        And (outFile33.Length = 1) And (outFile34.Length = 1) And (outFile35.Length = 1)) Then
            System.IO.File.Delete(FileToDelete)
        Else

        End If
    End Sub
ASKER CERTIFIED SOLUTION
Avatar of prosh0t
prosh0t

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of AkisC
AkisC
Flag of Greece image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of gr8life
gr8life

ASKER

Thank you, I ended up using parts of both your suggestions.
Gr8life