VB.NET网站下载文件
vb.net吧
全部回复
仅看楼主
level 1
angere之泪 楼主
大神求助,VB.NET开发网站怎么样把BLOB下载保存原来文件格式,类似网页下载文件功能
2019年07月09日 10点07分 1
level 1
angere之泪 楼主
GridView1.DataSource = LeafData
GridView1.DataBind()
If (GridView1.Rows.Count = 0) Then
MsgBox("此ID无记录!", 26, "提示")
End If
Dim ds As New DataSet()
LeafSqlDataAdapter.Fill(ds)
If ds.Tables(0).Rows.Count > 0 Then
Dim TempBytes() As Byte = ds.Tables(0).Rows(0)("文件夹")
'Dim FileStr As New FileStream(fPath, FileMode.Create, FileAccess.Write)
'FileStr.Write(TempBytes, 0, TempBytes.Length - 1)
'FileStr.Close()
Dim fPath As String = ds.Tables(0).Rows(0)("文件名")
Dim fileInfo As System.IO.FileInfo = New System.IO.FileInfo(fPath)
Response.Clear()
Response.ClearHeaders()
Response.Buffer = False
Response.ContentType = "application/octet-stream"
'Response.AddHeader("content-disposition", "attachment;filename=" + HttpUtility.UrlEncode(fileInfo.Name.ToString(), System.Text.Encoding.UTF8))
Response.AddHeader("content-disposition", "attachment;filename=" + HttpUtility.UrlEncode(fileInfo.Name, System.Text.Encoding.UTF8))
Response.AddHeader("content-length", fileInfo.Length.ToString())
Dim FileStr As New FileStream(fPath, FileMode.Create, FileAccess.Write)
FileStr.Write(TempBytes, 0, TempBytes.Length - 1)
FileStr.Close()
Response.BinaryWrite(TempBytes)
Response.ContentEncoding = System.Text.Encoding.Default
Response.WriteFile(fPath)
Response.Flush()
Response.End()
2019年07月12日 09点07分 2
level 1
angere之泪 楼主
2019年07月12日 09点07分 3
数据库和网页相关都没接触过[喷]不懂
2019年07月12日 09点07分
@TERA_ARISU [泪]遇到难题,还想说用VB.ET来试下做个网站下载文件
2019年07月12日 23点07分
level 1
angere之泪 楼主
@二笔青年
大神求助
2019年07月12日 09点07分 4
level 1
angere之泪 楼主
弹出保存的怎么是网页内容,而不是数据库的BLOB的内容?
2019年07月12日 09点07分 5
level 1
你不应用数字或string 去接收BLOB的数据
要用byte()数组...然后把数组写入文件就行
如果BLOB是语句排列
也要用byte()数组取得后再用getstring转成語句
2021年09月19日 10点09分 8
1