codice:Private Sub scarica_mp3() 'Download stringa rtf Dim messaggioErrore As String = "" Dim filePath As String = Me.Server.MapPath("Track01.mp3") Dim fi As FileInfo = New FileInfo(filePath) If Not fi.Exists Then messaggioErrore = "file non esistente" End If If messaggioErrore = "" Then ' imposta le headers Response.Clear() Response.AddHeader("Content-Disposition", "attachment; filename=""" & fi.Name & """") Response.AddHeader("Content-Length", fi.Length.ToString()) Response.ContentType = "application/octet-stream" ' leggo dal file e scrivo nello stream di risposta Response.WriteFile(filePath) Response.End() Else Response.Write(String.Format("<script>alert(""{0}"");</script>", libreria.toStringaJS(messaggioErrore))) Response.Flush() Response.End() End If End Sub

Rispondi quotando