2014-04-21 3 views
0

업데이트 대화 상자가 있는데 "직접 다운로드"버튼을 누르면 드롭 박스 위치에서 exe 파일을 다운로드하는 데 사용됩니다. 그러나 이제는 파일을 더 이상 다운로드하지 않으며 다운로드 후 파일을 시작하려고하지만 파일을 찾을 수 없습니다.내 VB 프로젝트에서 exe 파일을 다운로드하지 못했습니다.

Dim TempPath As String = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) & "\Temp" 
    Try 
     My.Computer.FileSystem.DeleteFile(TempPath & "\animeygocardmaker.exe") 
     My.Computer.Network.DownloadFile("https://dl.dropboxusercontent.com/u/72383434/animeygocardmaker.exe", TempPath & "\animeygocardmaker.exe") 
    Catch ex As Exception 
     MsgBox("An error occured while trying to download the file") 
    End Try 

    System.Diagnostics.Process.Start(TempPath & "\animeygocardmaker.exe") 
    Dim CloseAllWindows As New CloseAll 
    Form1.Pause() 
    CloseAllWindows.CloseAll() 

을 내가 말했듯이 항상 작동하는 데 사용 :

코드입니다. 파일을 다운로드하는 데 너무 오래 걸리는 것이 문제일까요?

+0

첫째, 정말 잘 구조화 된 코드입니까? Try ... Catch 블록 안에 다운로드가되어있어 실패 할 수 있음을 인정하지만 아직 Process.Start를 호출하여 파일이 이미 존재 함을 보장하는 것처럼 실행합니다. 말이 돼? 또한, 같은 경로를 세 번 건설하는 것이 합리적입니까? MsgBox는 무언가가 잘못되어 아무 것도 표시되지 않았기 때문에 쓸모가 없습니다. 예외가 발생하면 예외를 조사하여 가능한 모든 정보를 얻습니다. – jmcilhinney

+0

그래, 나는 네가 말했을 때 깨달았다. 나는 항상 그 코드를 사용했기 때문에 그 코드에 붙어 있었다. 말해 주셔서 고마워요 –

답변

0
 Dim TempPath As String = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) & "\Temp" 
    Try 
     My.Computer.Network.DownloadFile("https://dl.dropboxusercontent.com/u/72383434/animeygocardmaker.exe", TempPath & "\animeygocardmaker.exe") 

     System.Diagnostics.Process.Start(TempPath & "\animeygocardmaker.exe") 
     Dim CloseAllWindows As New CloseAll 
     Form1.Pause() 

    Catch ex As Exception 
     MsgBox("An error occured while trying to download the file" + ex.ToString) 
    End Try 
    CloseAllWindows.CloseAll() 
+0

어이 젠체하는 그 작품, 고마워요! –

관련 문제