vb.net workflow to upload .cab file and extract contents

Here is what I am looking to do:

1. Upload .cab file
2. Once .cab file is uploaded run a process to extract the file using 7-zip
3. Once the file is extracted perform additional processing that is already coded.

The problem is once i start the upload 7-zip wants to run right away before the file is complete. The .cab files can range in size from 30MB all the way up to 200MB so I don't think a timer is the best option. Ideally there must be some way to have a confirmation the file is uploaded and a confirmation on when the cab is extracted.
LVL 1
newimagentAsked:
Who is Participating?
 
CodeCruiserCommented:
I would change it to below


While Not (File.Exists(txtPath.Text & "\SystemInfo\SysConfigResult.log") And File.Exists(txtPath.Text & "\SnapDriveInfo\SnapDrive_RegistryInfo.log") 
End While
                If rdoDataSource.SelectedIndex = 0 Then
                    CheckWinDC()
                    If rdoDataSource.SelectedIndex = 1 Then
                        'In the future this will be Check_nSANity
                    End If
                End If
            End If

Open in new window

0
 
CodeCruiserCommented:
How are you uploading the file and how do you launch 7 zip?
0
 
newimagentAuthor Commented:
file is uploaded using the file upload control and a button to save the upload. 7-zip is launched using process.start
0
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

 
CodeCruiserCommented:
So you mean after calling the SaveAs on the file, and launching the 7-zip, the file is not written to disk yet?
0
 
newimagentAuthor Commented:
Yes, after calling the SaveAs 7-zip immediately starts. There needs to be a delay as the file is not fully uploaded when zip attempts to extract. how can i code in some kind of logic that makes sure the file is fully uploaded before the 7-zip process is kicked off?
0
 
CodeCruiserCommented:
The only way I can think of right now is that after calling the save method, add a while loop which keeps running and keeps trying to open the file. If there is an exception, it waits a bit and then tries again. If it succeeds, it exits the loop and launches 7-zip.
0
 
newimagentAuthor Commented:
I think you are on the right track. how can I write a do loop that checks if multiple files exist and once that returns true proceed with the processing? The below seems to be an infinite loop. I basically need the loop to check if the files exist and once they do run the CheckWinDC sub.


Do
            If File.Exists(txtPath.Text & "\SystemInfo\SysConfigResult.log") And File.Exists(txtPath.Text & "\SnapDriveInfo\SnapDrive_RegistryInfo.log") Then
                If rdoDataSource.SelectedIndex = 0 Then
                    CheckWinDC()
                    If rdoDataSource.SelectedIndex = 1 Then
                        'In the future this will be Check_nSANity
                    End If
                End If
            End If
        Loop

Open in new window

0
 
CodeCruiserCommented:
May be add a thread.sleep within while.
0
 
newimagentAuthor Commented:
Thanks! That works!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.