VB.net取程序路径经验总结

前端之家收集整理的这篇文章主要介绍了VB.net取程序路径经验总结前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

1、

(1)取程序运行的绝对路径用 application.startuppath()

(2)CurDir是当前运行路径,但如果期间进行了打开文件或其它改变路径的操作后, CurDir返回的可能就不是程序运行的路径了,所以不推荐使用。

(3)web方式: Server.MapPath()

2、让用户选择文件夹,取得文件夹所在的路径

Private Sub ButtonMSelect_Click(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles ButtonMSelect.Click
' Dim openDialog As New OpenFileDialog
Dim ofd As New FolderBrowserDialog
If ofd.ShowDialog() = Windows.Forms.DialogResult.OK Then
Me.TextBoxMPath.Text = ofd.SelectedPath

Dim getDir() As String
getDir = IO.Directory.GetFiles(Me.TextBoxMPath.Text.ToString)
'得到路径下所有的文件的路径

End If

End Sub

原文链接:https://www.f2er.com/vb/261764.html

猜你在找的VB相关文章