Better Way to Download Zip file From Server Using VB.Net











up vote
-1
down vote

favorite












Developing Windows Application for Download zip file from server,
Using VB.Net(I am using Microsoft Visual Basic 2008 Express Edition)



I am doing following functionality




  1. Download zip file from server

  2. Extract Zip file to Folder, once Extraction finished then Delete Downloaded zip file.

  3. Showing Splash screen while Downloading


In this case I am Triggering Download function inside Background Worker for show splash screen , But Unable to Close Splash screen after Download




Please help How to Close Splashscreen




Triggering FTP Download Using Background Worker in form load event



    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
BackgroundWorker1.RunWorkerAsync()
SplashScreen1.ShowDialog()
Catch ex As Exception
MsgBox(ex.Message.ToString(), MsgBoxStyle.Critical, "Error Message")
End Try
End Sub


Background Worker



Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
Try
'FTP Download Successful then Goto Unzip folder
If FTPDownload() = True Then
'Unzip Successful then Delete zip folder
If UnZip() = True Then
'Delete Zip file
If System.IO.File.Exists("D:LoginApp_Exev4.zip") = True Then
System.IO.File.Delete("D:LoginApp_Exev4.zip")
Else
MsgBox("Unable to Delete Zip file - File Not found", MsgBoxStyle.Critical, "Error Message")
End If
Else
MsgBox("Unable to Un Zip file", MsgBoxStyle.Critical, "Error Message")
End If
Else
MsgBox("File Download Failed", MsgBoxStyle.Critical, "Error Message")
End If
Catch ex As Exception
MsgBox(ex.Message.ToString(), MsgBoxStyle.Critical, "Error Message")
End Try
SplashScreen1.Dispose()
SplashScreen1.Close()
End Sub


Custom function for Download Zip file from Server



Private Function FTPDownload() As Boolean
Try
Using ftpClient As New WebClient()
ftpClient.Credentials = New System.Net.NetworkCredential("username", "password")
ftpClient.DownloadFile("ftp://Domain.com/v4/v4.zip", "D:LoginApp_Exev4.zip")
End Using
Catch ex As Exception
Return False
End Try
Return True
End Function


Having Some Doubts



Read Answer from this page https://stackoverflow.com/questions/4988286/what-difference-is-there-between-webclient-and-httpwebrequest-classes-in-net#answer-4988325



Here I am using WebClient for Download zip file, Which is Right method or not ?
Should Use FtpWebRequest ?



I did not Understand What is Difference Between WebClient & FTP Web Request



Please Can anyone Explain What is Response Stream and Stream Reader from above link.



And from above link WebClient Does not have timeout Property,
Please suggest correction for above code how to implement Code for handle Problem regarding Internet Connection Issues and timeout while Downloading



Custom Function for Unzip functionality



Note:- In this case I am using Ionic DLL for Extract zip file



Link of Ionic DLL https://www.dropbox.com/s/vcqjqlfieh7r6rq/Ionic.Zip.dll



Private Function UnZip() As Boolean
Try
ZipFolderName = "D:LoginApp_Exev4.zip"
Using zip As Ionic.Zip.ZipFile = Ionic.Zip.ZipFile.Read(ZipFolderName)

If Directory.Exists("D:\LoginApp_Exe\v4") Then
Directory.Delete("D:\LoginApp_Exe\v4", True)
End If

zip.ExtractAll("D:\LoginApp_Exe\v4")
End Using
Catch ex As Exception
Return False
End Try
Return True
End Function


Code Inside SplashScreen1.vb



Public NotInheritable Class SplashScreen1
Private Sub SplashScreen1_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load

ProgressBar1.Style = ProgressBarStyle.Marquee
ProgressBar1.MarqueeAnimationSpeed = 60
ProgressBar1.Refresh()
End Sub
End Class









share|improve this question


























    up vote
    -1
    down vote

    favorite












    Developing Windows Application for Download zip file from server,
    Using VB.Net(I am using Microsoft Visual Basic 2008 Express Edition)



    I am doing following functionality




    1. Download zip file from server

    2. Extract Zip file to Folder, once Extraction finished then Delete Downloaded zip file.

    3. Showing Splash screen while Downloading


    In this case I am Triggering Download function inside Background Worker for show splash screen , But Unable to Close Splash screen after Download




    Please help How to Close Splashscreen




    Triggering FTP Download Using Background Worker in form load event



        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Try
    BackgroundWorker1.RunWorkerAsync()
    SplashScreen1.ShowDialog()
    Catch ex As Exception
    MsgBox(ex.Message.ToString(), MsgBoxStyle.Critical, "Error Message")
    End Try
    End Sub


    Background Worker



    Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
    Try
    'FTP Download Successful then Goto Unzip folder
    If FTPDownload() = True Then
    'Unzip Successful then Delete zip folder
    If UnZip() = True Then
    'Delete Zip file
    If System.IO.File.Exists("D:LoginApp_Exev4.zip") = True Then
    System.IO.File.Delete("D:LoginApp_Exev4.zip")
    Else
    MsgBox("Unable to Delete Zip file - File Not found", MsgBoxStyle.Critical, "Error Message")
    End If
    Else
    MsgBox("Unable to Un Zip file", MsgBoxStyle.Critical, "Error Message")
    End If
    Else
    MsgBox("File Download Failed", MsgBoxStyle.Critical, "Error Message")
    End If
    Catch ex As Exception
    MsgBox(ex.Message.ToString(), MsgBoxStyle.Critical, "Error Message")
    End Try
    SplashScreen1.Dispose()
    SplashScreen1.Close()
    End Sub


    Custom function for Download Zip file from Server



    Private Function FTPDownload() As Boolean
    Try
    Using ftpClient As New WebClient()
    ftpClient.Credentials = New System.Net.NetworkCredential("username", "password")
    ftpClient.DownloadFile("ftp://Domain.com/v4/v4.zip", "D:LoginApp_Exev4.zip")
    End Using
    Catch ex As Exception
    Return False
    End Try
    Return True
    End Function


    Having Some Doubts



    Read Answer from this page https://stackoverflow.com/questions/4988286/what-difference-is-there-between-webclient-and-httpwebrequest-classes-in-net#answer-4988325



    Here I am using WebClient for Download zip file, Which is Right method or not ?
    Should Use FtpWebRequest ?



    I did not Understand What is Difference Between WebClient & FTP Web Request



    Please Can anyone Explain What is Response Stream and Stream Reader from above link.



    And from above link WebClient Does not have timeout Property,
    Please suggest correction for above code how to implement Code for handle Problem regarding Internet Connection Issues and timeout while Downloading



    Custom Function for Unzip functionality



    Note:- In this case I am using Ionic DLL for Extract zip file



    Link of Ionic DLL https://www.dropbox.com/s/vcqjqlfieh7r6rq/Ionic.Zip.dll



    Private Function UnZip() As Boolean
    Try
    ZipFolderName = "D:LoginApp_Exev4.zip"
    Using zip As Ionic.Zip.ZipFile = Ionic.Zip.ZipFile.Read(ZipFolderName)

    If Directory.Exists("D:\LoginApp_Exe\v4") Then
    Directory.Delete("D:\LoginApp_Exe\v4", True)
    End If

    zip.ExtractAll("D:\LoginApp_Exe\v4")
    End Using
    Catch ex As Exception
    Return False
    End Try
    Return True
    End Function


    Code Inside SplashScreen1.vb



    Public NotInheritable Class SplashScreen1
    Private Sub SplashScreen1_Load(ByVal sender As Object, ByVal e As
    System.EventArgs) Handles Me.Load

    ProgressBar1.Style = ProgressBarStyle.Marquee
    ProgressBar1.MarqueeAnimationSpeed = 60
    ProgressBar1.Refresh()
    End Sub
    End Class









    share|improve this question
























      up vote
      -1
      down vote

      favorite









      up vote
      -1
      down vote

      favorite











      Developing Windows Application for Download zip file from server,
      Using VB.Net(I am using Microsoft Visual Basic 2008 Express Edition)



      I am doing following functionality




      1. Download zip file from server

      2. Extract Zip file to Folder, once Extraction finished then Delete Downloaded zip file.

      3. Showing Splash screen while Downloading


      In this case I am Triggering Download function inside Background Worker for show splash screen , But Unable to Close Splash screen after Download




      Please help How to Close Splashscreen




      Triggering FTP Download Using Background Worker in form load event



          Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
      Try
      BackgroundWorker1.RunWorkerAsync()
      SplashScreen1.ShowDialog()
      Catch ex As Exception
      MsgBox(ex.Message.ToString(), MsgBoxStyle.Critical, "Error Message")
      End Try
      End Sub


      Background Worker



      Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
      Try
      'FTP Download Successful then Goto Unzip folder
      If FTPDownload() = True Then
      'Unzip Successful then Delete zip folder
      If UnZip() = True Then
      'Delete Zip file
      If System.IO.File.Exists("D:LoginApp_Exev4.zip") = True Then
      System.IO.File.Delete("D:LoginApp_Exev4.zip")
      Else
      MsgBox("Unable to Delete Zip file - File Not found", MsgBoxStyle.Critical, "Error Message")
      End If
      Else
      MsgBox("Unable to Un Zip file", MsgBoxStyle.Critical, "Error Message")
      End If
      Else
      MsgBox("File Download Failed", MsgBoxStyle.Critical, "Error Message")
      End If
      Catch ex As Exception
      MsgBox(ex.Message.ToString(), MsgBoxStyle.Critical, "Error Message")
      End Try
      SplashScreen1.Dispose()
      SplashScreen1.Close()
      End Sub


      Custom function for Download Zip file from Server



      Private Function FTPDownload() As Boolean
      Try
      Using ftpClient As New WebClient()
      ftpClient.Credentials = New System.Net.NetworkCredential("username", "password")
      ftpClient.DownloadFile("ftp://Domain.com/v4/v4.zip", "D:LoginApp_Exev4.zip")
      End Using
      Catch ex As Exception
      Return False
      End Try
      Return True
      End Function


      Having Some Doubts



      Read Answer from this page https://stackoverflow.com/questions/4988286/what-difference-is-there-between-webclient-and-httpwebrequest-classes-in-net#answer-4988325



      Here I am using WebClient for Download zip file, Which is Right method or not ?
      Should Use FtpWebRequest ?



      I did not Understand What is Difference Between WebClient & FTP Web Request



      Please Can anyone Explain What is Response Stream and Stream Reader from above link.



      And from above link WebClient Does not have timeout Property,
      Please suggest correction for above code how to implement Code for handle Problem regarding Internet Connection Issues and timeout while Downloading



      Custom Function for Unzip functionality



      Note:- In this case I am using Ionic DLL for Extract zip file



      Link of Ionic DLL https://www.dropbox.com/s/vcqjqlfieh7r6rq/Ionic.Zip.dll



      Private Function UnZip() As Boolean
      Try
      ZipFolderName = "D:LoginApp_Exev4.zip"
      Using zip As Ionic.Zip.ZipFile = Ionic.Zip.ZipFile.Read(ZipFolderName)

      If Directory.Exists("D:\LoginApp_Exe\v4") Then
      Directory.Delete("D:\LoginApp_Exe\v4", True)
      End If

      zip.ExtractAll("D:\LoginApp_Exe\v4")
      End Using
      Catch ex As Exception
      Return False
      End Try
      Return True
      End Function


      Code Inside SplashScreen1.vb



      Public NotInheritable Class SplashScreen1
      Private Sub SplashScreen1_Load(ByVal sender As Object, ByVal e As
      System.EventArgs) Handles Me.Load

      ProgressBar1.Style = ProgressBarStyle.Marquee
      ProgressBar1.MarqueeAnimationSpeed = 60
      ProgressBar1.Refresh()
      End Sub
      End Class









      share|improve this question













      Developing Windows Application for Download zip file from server,
      Using VB.Net(I am using Microsoft Visual Basic 2008 Express Edition)



      I am doing following functionality




      1. Download zip file from server

      2. Extract Zip file to Folder, once Extraction finished then Delete Downloaded zip file.

      3. Showing Splash screen while Downloading


      In this case I am Triggering Download function inside Background Worker for show splash screen , But Unable to Close Splash screen after Download




      Please help How to Close Splashscreen




      Triggering FTP Download Using Background Worker in form load event



          Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
      Try
      BackgroundWorker1.RunWorkerAsync()
      SplashScreen1.ShowDialog()
      Catch ex As Exception
      MsgBox(ex.Message.ToString(), MsgBoxStyle.Critical, "Error Message")
      End Try
      End Sub


      Background Worker



      Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
      Try
      'FTP Download Successful then Goto Unzip folder
      If FTPDownload() = True Then
      'Unzip Successful then Delete zip folder
      If UnZip() = True Then
      'Delete Zip file
      If System.IO.File.Exists("D:LoginApp_Exev4.zip") = True Then
      System.IO.File.Delete("D:LoginApp_Exev4.zip")
      Else
      MsgBox("Unable to Delete Zip file - File Not found", MsgBoxStyle.Critical, "Error Message")
      End If
      Else
      MsgBox("Unable to Un Zip file", MsgBoxStyle.Critical, "Error Message")
      End If
      Else
      MsgBox("File Download Failed", MsgBoxStyle.Critical, "Error Message")
      End If
      Catch ex As Exception
      MsgBox(ex.Message.ToString(), MsgBoxStyle.Critical, "Error Message")
      End Try
      SplashScreen1.Dispose()
      SplashScreen1.Close()
      End Sub


      Custom function for Download Zip file from Server



      Private Function FTPDownload() As Boolean
      Try
      Using ftpClient As New WebClient()
      ftpClient.Credentials = New System.Net.NetworkCredential("username", "password")
      ftpClient.DownloadFile("ftp://Domain.com/v4/v4.zip", "D:LoginApp_Exev4.zip")
      End Using
      Catch ex As Exception
      Return False
      End Try
      Return True
      End Function


      Having Some Doubts



      Read Answer from this page https://stackoverflow.com/questions/4988286/what-difference-is-there-between-webclient-and-httpwebrequest-classes-in-net#answer-4988325



      Here I am using WebClient for Download zip file, Which is Right method or not ?
      Should Use FtpWebRequest ?



      I did not Understand What is Difference Between WebClient & FTP Web Request



      Please Can anyone Explain What is Response Stream and Stream Reader from above link.



      And from above link WebClient Does not have timeout Property,
      Please suggest correction for above code how to implement Code for handle Problem regarding Internet Connection Issues and timeout while Downloading



      Custom Function for Unzip functionality



      Note:- In this case I am using Ionic DLL for Extract zip file



      Link of Ionic DLL https://www.dropbox.com/s/vcqjqlfieh7r6rq/Ionic.Zip.dll



      Private Function UnZip() As Boolean
      Try
      ZipFolderName = "D:LoginApp_Exev4.zip"
      Using zip As Ionic.Zip.ZipFile = Ionic.Zip.ZipFile.Read(ZipFolderName)

      If Directory.Exists("D:\LoginApp_Exe\v4") Then
      Directory.Delete("D:\LoginApp_Exe\v4", True)
      End If

      zip.ExtractAll("D:\LoginApp_Exe\v4")
      End Using
      Catch ex As Exception
      Return False
      End Try
      Return True
      End Function


      Code Inside SplashScreen1.vb



      Public NotInheritable Class SplashScreen1
      Private Sub SplashScreen1_Load(ByVal sender As Object, ByVal e As
      System.EventArgs) Handles Me.Load

      ProgressBar1.Style = ProgressBarStyle.Marquee
      ProgressBar1.MarqueeAnimationSpeed = 60
      ProgressBar1.Refresh()
      End Sub
      End Class






      vb.net ftp






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 6 hours ago









      Relax

      94




      94



























          active

          oldest

          votes











          Your Answer





          StackExchange.ifUsing("editor", function () {
          return StackExchange.using("mathjaxEditing", function () {
          StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
          StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
          });
          });
          }, "mathjax-editing");

          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "196"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














           

          draft saved


          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f207628%2fbetter-way-to-download-zip-file-from-server-using-vb-net%23new-answer', 'question_page');
          }
          );

          Post as a guest





































          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















           

          draft saved


          draft discarded



















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f207628%2fbetter-way-to-download-zip-file-from-server-using-vb-net%23new-answer', 'question_page');
          }
          );

          Post as a guest




















































































          Popular posts from this blog

          Morgemoulin

          Scott Moir

          Souastre