我已經找了幾天,沒有運氣。將文件保存到用戶計算機在VB.Net
誰能告訴我如何將文件保存到VB.Net到任何計算機?有文章丟失,但這些只會告訴你保存到自己的計算機通過提供文件夾訪問,而不是隨機用戶的計算機。
你可以看到我的例子在這裏http://hanontest.com/POShellCreator.aspx(你必須輸入文本的任務代碼,項目ID和註釋字段,然後點擊創建。然後單擊導出,你會看到錯誤。)
我可以去一家當地比薩店的網站和一個菜單下載pdf,我知道它是可能的。
在我的例子中,當你點擊按鈕時,它會保存,如果有人知道如何做到這一點,我想保存爲對話框。
這裏是保存字符串:
Dim regDate As Date = Date.Now()
Dim strDate As String = regDate.ToString(".yyyy\.MM\.dd")
TextBox5.Text = "c:\temp\" & Vendor & "&" & Vendor2 & "&" & Vendor3 & "&" & Vendor4 & TaskEmpty & strDate & ".csv"
這裏是我現在的儲蓄:
Public Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
'Define Path to save file.
Dim path As String = TextBox5.Text
' Create or overwrite the file.
Dim fs As FileStream = File.Create(path)
' Add text to the file.
Dim info As Byte() = New UTF8Encoding(True).GetBytes(TextBox3.Text)
fs.Write(info, 0, info.Length)
fs.Close()
End Sub
如果這是一個ASP.NET應用程序,那麼您的服務器端代碼無法將文件直接保存到在瀏覽器中查看您網站的人的機器上。他們必須從URL下載文件。該URL可能是您保存的服務器上的實際文件,也可能是按需生成的數據。 – jmcilhinney 2014-09-04 00:03:47