Tengo una WEB en la que ofrezco descargar videos personales :D
Al descargar imagenes y archivos relativamente pequenos no hay problema.
Pero si son muy grandes como 700 mb incluso menos, me da error.
esta es mi funcion:
Dim reqFTP As FtpWebRequest
Dim fileName As String = System.IO.Path.GetFileName(Me.UrlString)
Dim descFilePath As String = System.IO.Path.Combine(Me.DestDir, fileName)
Try
reqFTP = DirectCast(FtpWebRequest.Create(Me.UrlString), FtpWebRequest)
reqFTP.Method = WebRequestMethods.Ftp.DownloadFile
reqFTP.UseBinary = True
Using outputStream As New FileStream(descFilePath, FileMode.OpenOrCreate)
Using response As FtpWebResponse = DirectCast(reqFTP.GetResponse(), FtpWebResponse)
Using ftpStream As Stream = response.GetResponseStream()
Dim bufferSize As Integer = 2048
Dim readCount As Integer
Dim buffer As Byte() = New Byte(bufferSize - 1) {}
readCount = ftpStream.Read(buffer, 0, bufferSize)
While readCount > 0
outputStream.Write(buffer, 0, readCount)
readCount = ftpStream.Read(buffer, 0, bufferSize)
End While
End Using
End Using
End Using
Return True
Catch ex As Exception
Throw New Exception("Failed to download", ex.InnerException)
End Try
End Function
Alguien tiene idea de algun metodo de como descargar un archivo externo de 4gb via asp.net al PC del cliente.
Se agradecera alguna ayuda.
No me vale response.redirect(Tengo mis motivos)
Saludos.
Me equivoque de funcion esa es para ftp.
Public Overrides Function DownloadFile() As Boolean
Dim fileName As String = System.IO.Path.GetFileName(Me.UrlString)
Dim descFilePath As String = System.IO.Path.Combine(Me.DestDir, fileName)
Try
Dim myre As WebRequest = WebRequest.Create(Me.UrlString)
Catch ex As Exception
Throw New Exception("File doesn't exist on server", ex.InnerException)
End Try
Try
Dim fileData As Byte()
Using client As New WebClient()
fileData = client.DownloadData(Me.UrlString)
End Using
Using fs As New FileStream(descFilePath, FileMode.OpenOrCreate)
fs.Write(fileData, 0, fileData.Length)
End Using
Return True
Catch ex As Exception
Throw New Exception("Failed to download", ex.InnerException)
End Try
End Function
Por favor alquna sugerencia al menos.Para descargar archivos extrernos de otro dominio de mi propiedad.(Hasta 4 gb.)Saludos