導航:首頁 > 文件教程 > 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中打開本地文件相關的資料

熱點內容
cad2015文件參照怎麼關閉 瀏覽:678
最小二乘逼近程序 瀏覽:610
鐵路12306密碼找不回 瀏覽:352
默認網路覆蓋的腦區 瀏覽:319
itunes恢復iphone教程 瀏覽:292
爐石現在是什麼版本 瀏覽:825
word兼容包安裝報錯 瀏覽:528
iphone5s包裝4g沒有氣孔 瀏覽:814
html包含文件代碼嗎 瀏覽:50
蘋果appstore日本賬號 瀏覽:532
解密dg加密的文件 瀏覽:206
gsh6什麼格式文件 瀏覽:507
dnf85版本覺醒任務 瀏覽:998
范冰冰蘋果百度雲盤資源鏈接 瀏覽:507
資料庫主機是什麼系統 瀏覽:812
pdf表單教程 瀏覽:715
百度瀏覽器去更新安卓破解版 瀏覽:855
光碟內部應用程序錯誤 瀏覽:83
iphone6升級ios9步驟 瀏覽:873
魔力代碼 瀏覽:497

友情鏈接