怎么写下载程序?谢谢

ustc2007 2008-10-28 04:58:06
想要写一个类似于FLASHGET的下载程序,HTML或者FTP下载协议都可以,我不知道哪个简单,需要用到什么技术呢?
服务器端要自己写么?
请帮帮忙,只要指导性的就可以,具体的东西我自己去学
谢谢了!
...全文
219 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhangpeiwen168 2008-11-21
  • 打赏
  • 举报
回复
http://www.builder.com.cn/2007/0927/524820.shtml
zhangpeiwen168 2008-11-21
  • 打赏
  • 举报
回复
函数名:ResponseFile
功能 :客户端从服务器端下载一个文件
返回值:返回True表示服务器响应成功,返回False表示失败
参数 :
PageResponse 响应客户端的Response对象,用Page.Response引用
DownloadFileName 客户端下载文件的文件名
LocalFilePath 服务器端待下载文件的路径
DownloadBuffer 服务器端读取文件的缓冲区大小,单位为KB



Public Function ResponseFile(ByRef PageResponse As HttpResponse, ByVal DownloadFileName As String, ByVal LocalFilePath As String, ByVal DownloadBuffer As Long) As Boolean
Dim Reader As System.IO.FileStream
Dim Buffer() As Byte
Dim FileLength As Long
Dim FileBuffer As Long = 1024 * DownloadBuffer
Dim ReadCount As Long
ReadCount = FileBuffer
ReDim Buffer(ReadCount - 1)
Try
Reader = System.IO.File.OpenRead(LocalFilePath)
FileLength = Reader.Length
Try
PageResponse.Buffer = False
PageResponse.AddHeader("Connection", "Keep-Alive")
PageResponse.ContentType = "application/octet-stream"
PageResponse.AddHeader("Content-Disposition", "attachment;filename=" + DownloadFileName)
PageResponse.AddHeader("Content-Length", FileLength.ToString)
While ReadCount = FileBuffer
ReadCount = Reader.Read(Buffer, 0, FileBuffer)
ReDim Preserve Buffer(ReadCount - 1)
PageResponse.BinaryWrite(Buffer)
End While
Response.End()
Catch ex As Exception
Return False
Finally
Reader.Close()
End Try
Catch ex As Exception
Return False
End Try
Return True
End Function

liye9801 2008-11-08
  • 打赏
  • 举报
回复
我上传过一个Http下载的源码.可以去下载..
lucky500 2008-11-08
  • 打赏
  • 举报
回复
还是要多学习啊。都是高手
ustc2007 2008-10-28
  • 打赏
  • 举报
回复
真的是太感谢你了,谢谢了,^_^。
ineedchrist 2008-10-28
  • 打赏
  • 举报
回复
给你个我写的下载图片的代码,其它的,多研究研究flashget,自己动动脑
''' <summary>
''' 从互联网上加载图片
''' </summary>
''' <param name="URL">互联网上的图片路径</param>
''' <param name="SaveImagePath">用于存储下载下来的图片的路径,不包含文件名</param>
''' <remarks></remarks>
Public Sub AddImageFromURL(ByVal URL As String, ByVal SaveImagePath As String)
_DownURL = URL
_SourceImageFullPath = SaveImagePath '& "\" &
If _SourceImageFullPath.Substring(_SourceImageFullPath.Length - 1, 1) <> "\" Then
_SourceImageFullPath = SaveImagePath & "\"
End If
Try
If System.IO.Directory.Exists(_SourceImageFullPath) = False Then
System.IO.Directory.CreateDirectory(_SourceImageFullPath)
End If
Catch ex As Exception

End Try
_SourceImageFullPath = _SourceImageFullPath & System.IO.Path.GetFileName(URL)
Dim t As New Threading.Thread(AddressOf DownFileThread)
t.Start()
End Sub

''' <summary>
''' 下载文件的线程事件
''' </summary>
''' <remarks></remarks>
Private Sub DownFileThread()
Dim Myrq As HttpWebRequest = HttpWebRequest.Create(_DownURL)
Dim myrp As HttpWebResponse = Myrq.GetResponse
Dim totalBytes As Long = myrp.ContentLength
'Prog.Maximum = totalBytes
Dim st As Stream = myrp.GetResponseStream
Dim so As Stream = New FileStream(_SourceImageFullPath, FileMode.Create)
Dim totalDownloadedByte As Long = 0
Dim by(500) As Byte
Dim osize As Integer = st.Read(by, 0, by.Length)
While osize > 0
totalDownloadedByte = osize + totalDownloadedByte
Application.DoEvents()
so.Write(by, 0, osize)
'DrawProgress(CInt(totalDownloadedByte / myrp.ContentLength * 100))
'Prog.Value = totalDownloadedByte
osize = st.Read(by, 0, by.LongLength)
End While
so.Close()
st.Close()
While True
If File.Exists(_SourceImageFullPath) Then

_SourceImage = Image.FromFile(_SourceImageFullPath)
SetImageFormat()
Example_GetThumb()
DrawNoSelect()
Exit While
End If
End While
End Sub

ustc2007 2008-10-28
  • 打赏
  • 举报
回复
实在不好意思,我是新来的,还没有分啊,以后定会补上
ineedchrist 2008-10-28
  • 打赏
  • 举报
回复
会了,哪个都简单,不会,哪个都不简单,服务器端如果你想自己写,可以自己写,如果不想自己写,可以找别人帮你写。
指导性的意见就是发帖要给分,不给分除了我说点,没人理你。

16,717

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧