導航:首頁 > 文件教程 > vbnet中打開本地文件

vbnet中打開本地文件

發布時間:2024-09-11 12:33:41

A. vb.net 打開文件

System.Windows.Forms.OpenFileDialog
System.Windows.Forms.SaveFileDialog
System.Windows.Forms.FolderBrowserDialog
以上三抄個類均襲能夠很好的解決樓主的需求。
具體的請lz自己查msdn

B. vb.net 打開word,怎麼獲取要打開的文件名

OpenFileDialog1.ShowDialog()
Dim s As String = OpenFileDialog1.FileName
MessageBox.Show(s)

C. 怎樣用vb.net讀取本地.txt文件

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
'向指定文件寫入數據
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

參考這個吧
'
'vb.net源代碼來自www.c-pet.com
'

D. 如何用vb.net 打開一個既存的txt文檔。

可以調用CMD

方法一:

Shell("cmd.exe/ccallc:新建文本文檔.txt",AppWinStyle.NormalFocus)

缺點:不但會打開文本文件,同時還會顯示一個cmd窗體。

方法二:

需要新建一個bat文件到資源里,輸入start C:新建文本文檔.txt

代碼

shell"bat文件的路徑.bat"

這樣就好了,兩種方法各有好壞。一個會顯示cmd窗體,一個需要bat文件。

閱讀全文

與vbnet中打開本地文件相關的資料

熱點內容
液晶怎麼看網路電視 瀏覽:121
如何壓縮掃描文件 瀏覽:180
clientserver教程 瀏覽:648
c語言素數程序 瀏覽:595
內孔r2倒角怎麼編程 瀏覽:985
微信群互動游戲有哪些 瀏覽:700
javaweb連接sqlserver 瀏覽:973
如何下載政姆龍plc編程軟體 瀏覽:838
linux打開iso文件 瀏覽:1
網路工程師技能能力 瀏覽:789
小原焊機編程器如何設置中文 瀏覽:299
蘋果數據線如何實現快充 瀏覽:423
ug布局在哪個文件夾 瀏覽:983
多份文件如何一鍵列印 瀏覽:675
ps填充圖案的源文件 瀏覽:90
pdt是什麼文件 瀏覽:959
蘋果跌下花屏 瀏覽:607
大數據如何創造業務價值 瀏覽:702
西瓜視頻如何轉移賬號數據 瀏覽:854
使用5g網路電視 瀏覽:998

友情鏈接