CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 2 of 2 FirstFirst 12
Results 16 to 18 of 18
  1. #16
    Join Date
    Nov 2005
    Location
    Omaha, Nebraska, USA
    Posts
    696

    Re: stderr / stdout: delete files if there's no error

    Personally, I would find it better to just modify the Find_Files function to suit your needs. That way you can get just the files after "Extracting from" and none other. I would assume the lines with the files you need to delete all begin with "Extracting from", so you could just seek out those lines and get the filenames from there.

    Also, Gremmy's method, while good, would not work correctly if they have a RAR file with a space in the file name. Worse if there is a space in the file path (i.e. any of the folders have a space in the name).

    If the output maintains a standard (i.e. always says "Extracting from <archive name>" when it gets a RAR file to extract and says "Extracting <file name>" when it extracts a file inside), you could use a much simpler method:
    Code:
    Public Sub Find_Files(ByVal Input_string As String, ByRef File_array() As String)
        Dim Tmp_Array() As String
        Dim Tmp_Loop As Long
        ReDim File_array(0)
        Tmp_Array = Split(Input_string, vbCrLf, -1, vbTextCompare) 'Split each line into it's own string line..
        For Tmp_Loop = 0 To UBound(Tmp_Array)
            If Left$(Tmp_Array(Tmp_Loop), 15) = "Extracting from" Then
                ReDim Preserve File_array(UBound(File_array) + 1)
                File_array(UBound(File_array)) = Right$(Tmp_Array(Tmp_Loop), Len(Tmp_Array(Tmp_Loop)) - 16)  '16 is the length of "Extracting from "
            End If
        Next
    End Sub
    That should work (you'll still get the first item in the passed array being blank).

  2. #17
    Join Date
    Jun 2005
    Location
    JHB South Africa
    Posts
    3,772

    Re: stderr / stdout: delete files if there's no error

    Haha Snap Chaos...

    Good Comments..

    I am still to find a method to use that first item in the array...

    Dont know why they made it that ubound wont return -1 for undimmed arrays... and why Redim Array (-1) errors

    Grem....
    Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
    WPF Articles : 3D Animation 1 , 2 , 3
    Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
    Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
    All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.

  3. #18
    Join Date
    Dec 2005
    Posts
    151

    Re: stderr / stdout: delete files if there's no error

    Thanks again

Page 2 of 2 FirstFirst 12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured