Dim strPath As String = Server.MapPath("xxx/xxx.xxx") '這里是你的文件路徑以及名稱后綴名,使用相對(duì)路徑即可,不過(guò)記得路徑最好是英文,用中文是否連接不到我就不知道了,記得是"/"哦! Page.Response.Clear() Page.Response.AddHeader("Content-Type", "text/xml") Page.Response.AddHeader("Content-Disposition", "attachment;filename=") Page.Response.WriteFile(strPath) Page.Response.End() 路徑的話你可以使用變量的 所以這樣一來(lái)需要下載的文件就會(huì)相當(dāng)靈活 順便附送一個(gè)刪除文件的方法 System.IO.File.Delete(Server.MapPath("xxx/xxx.xxx")) 不過(guò)刪除文件跟寫文件是一樣的 需要WEB服務(wù)器開啟可寫功能!、 好用的話記得給分哦 嘿嘿!
網(wǎng)站建設(shè)公司,為您提供網(wǎng)站建設(shè),網(wǎng)站制作,網(wǎng)頁(yè)設(shè)計(jì)及定制網(wǎng)站建設(shè)服務(wù),專注于企業(yè)網(wǎng)站建設(shè),高端網(wǎng)頁(yè)制作,對(duì)成都假山制作等多個(gè)行業(yè)擁有豐富的網(wǎng)站建設(shè)經(jīng)驗(yàn)的網(wǎng)站建設(shè)公司。專業(yè)網(wǎng)站設(shè)計(jì),網(wǎng)站優(yōu)化推廣哪家好,專業(yè)成都網(wǎng)站推廣優(yōu)化,H5建站,響應(yīng)式網(wǎng)站。
imports System.IO
讀取指定文件
'
'讀取指定文本文件
Public Function readtext(ByVal path As String)
If path = "" Then
readtext = "操作失敗!"
Exit Function
End If
Try
If File.Exists(path) = True Then
Dim fs As New FileStream(path, FileMode.Open)
Dim sr As New StreamReader(fs)
Dim str As String
str = sr.ReadToEnd.ToString
sr.Close()
fs.Close()
readtext = str
Else
readtext = "操作失?。?
End If
Catch ex As Exception
readtext = "操作失??!"
End Try
End Function
'向指定文件寫入數(shù)據(jù)
Public Function writetext(ByVal path As String, ByVal opi As Integer, ByVal msg As String)
If path = "" Then
writetext = "操作失敗!"
Exit Function
End If
Dim op As FileMode
Select Case opi
Case 1
op = FileMode.Append
Case 2
op = FileMode.Create
Case Else
op = FileMode.Create
End Select
Try
If File.Exists(path) = True Then
Dim fs As New FileStream(path, op)
Dim sr As New StreamWriter(fs)
sr.WriteLine(msg)
sr.Close()
fs.Close()
writetext = "操作完成!"
Else
writetext = "操作失??!"
End If
Catch ex As Exception
writetext = "操作失?。?
End Try
End Function
參考這個(gè)吧
'
'vb.net源代碼來(lái)自
'
用webBrowser可以設(shè)置代理IP嗎?
如果用webBrowser查看wap網(wǎng)頁(yè)的源文件,那代碼應(yīng)該怎么寫啊
Cookie丟了
登陸的時(shí)候,把CookieContainer保存下來(lái),可以設(shè)置一個(gè)全局變量,然后再getBody的時(shí)候,
request.Cookiecontainer設(shè)置為這個(gè)CookieContainer即可
Dim CtrlRange As Object
On Error Resume Next
Do
Err.Clear()
CtrlRange = Ie.Document.Body.DomElement.createControlRange()
CtrlRange.Add(Ie.Document.DomDocument.GetElementById("verifypic"))
CtrlRange.execCommand("Copy") '獲取驗(yàn)證碼
If Clipboard.ContainsData(DataFormats.Bitmap) Then
PictureBox1.Image = Clipboard.GetData(DataFormats.Bitmap) '在Picture1控件上顯示
End If
If Err.Number 0 Then WaitingMS(100) ‘延時(shí)
Loop While Err.Number 0
以前找的 vbnet里也可以用
沒有比這個(gè)更簡(jiǎn)單的了
Richtextbox1.text = Regex.Replace(Richtextbox1.text, " (\/\s*)?((\w+:)?\w+)(\w+(\s*=\s*(([ " " '])(\\[ " " ' 'tbnr]|[^\7])*?\7|\w+)|.{0})|\s)*?(\/\s*)? ", String.Empty)