none
Operazione di DownLoad da un Sito RRS feed

  • 질문

  • Ho sviluppato la seguente routine per scaricare dal sito un setup.exe ed eseguirlo

    Funziona ma scarica il file nella cartella di default c:\utenti\...

    Cosa devo fare per scaricare il file in una cartella definita da me ?



    [I have developed the following procedure to download from the site and run a setup.exe
    It works but download the file in the default folder c: \ users \ ...
    What should I do to download the file to a folder defined by me?]

     Private Sub DownLoad(ByVal sNomeR As String, ByVal sNomeE As String, ByVal sNome As String)
            Dim strRequest As String = sNomeR  'Request.QueryString("file") '-- if something was passed to the file querystring
            ' esempio : strRequest="\installa_pv4\setup.exe"
            Dim path As String = sNomeE  ' Server.MapPath(strRequest) 'get file object as FileInfo
            ' esempio : path="C:\Arcturus|Sito_ArcturusAT\installa_pv4\setup.exe"
            Dim file As System.IO.FileInfo = New System.IO.FileInfo(path) '-- if the file exists on the server :
            If file.Exists Then 'set appropriate headers
                Response.Clear()
                Response.AddHeader("Content-Disposition", "attachment; filename=" & sNome)
                ' esempio : file.name="setup.exe"
                Response.AddHeader("Content-Length", file.Length.ToString())
                Response.ContentType = "application/octet-stream"
                Response.WriteFile(sNomeE)
                Response.End() 'if file does not exist
            Else
                Response.Write("This file does not exist.")
            End If 'nothing in the URL as HTTP GET
        End Sub

    • 이동됨 Reed KimbleMVP 2013년 6월 25일 화요일 오후 8:44 asp.net in vb language
    2013년 6월 25일 화요일 오후 1:48

모든 응답