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文件。