命名空間:System.Windows.Forms
創(chuàng)新互聯(lián)公司主要從事做網(wǎng)站、網(wǎng)站建設(shè)、網(wǎng)頁設(shè)計、企業(yè)做網(wǎng)站、公司建網(wǎng)站等業(yè)務(wù)。立足成都服務(wù)嵊泗,10余年網(wǎng)站建設(shè)經(jīng)驗,價格優(yōu)惠、服務(wù)專業(yè),歡迎來電咨詢建站服務(wù):13518219792
Application.StartupPath 屬性(返回String)
獲取啟動了應(yīng)用程序的可執(zhí)行文件的路徑,不包括可執(zhí)行文件的名稱。
Application.ExecutablePath 屬性(返回String)
獲取啟動了應(yīng)用程序的可執(zhí)行文件的路徑,包括可執(zhí)行文件的名稱。
用Io.Directory.GetFiles("D:\")函數(shù)獲得一個存放D盤目錄文件的字符串?dāng)?shù)組
代碼:
For Each item As String In IO.Directory.GetFiles("D:\")
ListBox1.Items.Add(item)
Next
運行之后,ListBox1里就會有這些文件
Server.MapPath("~") "\" "Web.config"Server.MapPath("~") 是取當(dāng)前目錄上一級的路徑Server.MapPath(".") 是取當(dāng)前目錄的路徑
Vb.net獲取某個目錄下文件夾名稱(不包含隱藏文件夾)實現(xiàn)代碼如下:
Dim?dir?As?New?DirectoryInfo("D:\")
For?Each?d?As?DirectoryInfo?In?dir.GetDirectories
ComboBox1.Items.Add(d.Name)
Next
dim?finfo?as?new?fileinfo(d.name)
if?(finfo.attributes?and?FileAttributes.Hidden)FileAttributes.Hidden?then
ComboBox1.Items.Add(d.Name)
end?if
Dim
dir
As
New
IO.DirectoryInfo("C:\TDDownload")
//
目錄下就一個文件夾
If
dir.GetDirectories.Length
Then
MessageBox.Show(dir.GetDirectories.GetValue(0).ToString())
End
If
//
目錄下多個文件夾
'For
Each
d
As
IO.DirectoryInfo
In
dir.GetDirectories
'
MessageBox.Show(d.FullName)
'Next
vb.net:
Dim
path
=
System.IO.Directory.GetFiles("D:\Log\abc",
"*.txt",
SearchOption.AllDirectories):搜索該路徑下的所有txt類型的目錄及子目錄
path.AddRange(path)
Dim
_RecordInfo
As
String
Dim
_Reader
As
StreamReader
_Reader
=
New
StreamReader(file,
System.Text.Encoding.Default):'以Default編碼的形式讀取file文件(文件寫入的編碼要與讀取的編碼一致)
分享文章:vb.net獲取目錄 vb 下載文件到指定目錄
本文來源:http://chinadenli.net/article2/dodidic.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供微信小程序、網(wǎng)站策劃、網(wǎng)站維護(hù)、手機(jī)網(wǎng)站建設(shè)、響應(yīng)式網(wǎng)站、關(guān)鍵詞優(yōu)化
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)