--
甜版,执行红色代码时出现下图错误:
此主题相关图片如下:2345截图20170912190817.png
Case "test.htm"
wb.AddForm("","form1","test.htm")
dr = DataTables("合同评审").SQLFind("[_Identify]=296")
With wb.AddInputGroup("form1","ipg1","附件")
With .AddTextArea("附件",5)
.Value = dr("附件")
End With
End With
Dim file As String = dr("附件") \'含回车的多行文件名
Dim Lst() As String = file.Split(vbcrlf) \'文件名数组
If Lst.Length >0 Then \'如果有附件
With wb.AddListGroup("form1", "lsg", "查看附件")
If Lst.Length=1 Then \'只有一个附件
.Add("查看附件","查看附件", "", "download.htm?key=" & UrlEncode(lst(0))) \'附件的url编码
Else
For i = 0 To Lst.Length-1
.Add("查看附件" & i+1,"查看附件" & i+1, "", "download.htm?key=" & UrlEncode(lst(i)))
Next
End If
End With
End If
With wb.AddButtonGroup("form1","btg1",True)
.Add("btn1", "审批", "submit")
End With
Case "download.htm" \'选择查看附件1
Dim file As String = e.Values("key") \'file=/合同评审/申请人/A.docx
file = UrlDecode(file) \'url解码,不解码也可以,file=/合同评审/申请人/A.docx
Dim file1 As String = file.Replace("/","\\") \'file1=\\合同评审\\申请人\\A.docx
Dim idx1 As Integer = file1.LastIndexOf("\\") \'文件名中最后一个斜杆位置
Dim file2 As String = file1.SubString(idx1+1) \'获取不含路径的文件名,file2=A.docx
Dim file3 As String = "e:\\项目管理系统" & file1 \'附件上传时的服务器物理路径 file3=e:\\项目管理系统\\合同评审\\申请人\\A.docx
Dim fs As System.IO.FileStream = Nothing
fs = System.IO.File.Open(file3, System.IO.FileMode.Open) \'用file3
Dim btFile As Byte() = New Byte(fs.Length - 1) {}
fs.Read(btFile, 0, Convert.ToInt32(fs.Length))
fs.Close()
e.Response.Headers("Content-Disposition") = "attachment;filename=" & file \'用file1~file3都出错,无法继续
e.Response.ContentType = "application/octet-stream"
Dim output = e.response.OutputStream
output.Write(btFile,0,btFile.Length)
output.Close()
[此贴子已经被作者于2017/9/12 19:34:50编辑过]