EDN Admin
Well-known member
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_pv4setup.exe"
Dim path As String = sNomeE Server.MapPath(strRequest) get file object as FileInfo
esempio : path="C:Arcturus|Sito_ArcturusATinstalla_pv4setup.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
View the full article
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_pv4setup.exe"
Dim path As String = sNomeE Server.MapPath(strRequest) get file object as FileInfo
esempio : path="C:Arcturus|Sito_ArcturusATinstalla_pv4setup.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
View the full article