vb 怎麼把目錄內所有資料夾的路徑列在list1上

時間 2025-05-07 04:15:13

1樓:匿名使用者

dim inull as integer, lpidlist as long, lresult as long

dim spath as string, udtbi as browseinfo

on error resume next

with udtbi

set the owner window

hwndowner =

lstrcat appends the two strings and returns the memory address

lpsztitle = lstrcat("請選擇資料夾", 橘源標題圓返態。

世喊return only if the user selected a directory

ulflags = bif_returnonlyfsdirs

end with

show the 'browse for folder' dialog

lpidlist = shbrowseforfolder(udtbi)

if lpidlist then

spath = string$(max_path, 0)

get the path from the idlist

shgetpathfromidlist lpidlist, spath

free the block of memory

cotaskmemfree lpidlist

inull = instr(spath, vbnullchar)

if inull then

spath = left$(spath, inull - 1)

end if

end if這段能夠遍歷一級目錄,修改下就能夠偏離多極了,或網上收vb遍歷資料夾!

2樓:匿名使用者

右鍵 排列圖示 名稱。

vb如何取某個資料夾的檔案列表到list

3樓:網友

直接使用file控制項就可以了。

或者把file控制項的內容倒入到list1中。

4樓:呆兔子

= "【將此處替換為資料夾完整路徑】"

vb 如何讓list1中顯示乙個目錄下的所有檔案(包括子資料夾裡的檔案)?

5樓:網友

list1顯示d:\123\下面的所有檔案!

private sub command1_click()dim filename as string, mypath as string, k as integer

mypath = "d:\123\"

range("a1:a10") = ""

filename = dir(mypath & "*.*") 'dir可以顯示相應資料夾下面檔案的名字。

dok = k + 1

filename

filename = dir '在再=一次是因為不段的把檔案放進行(不懂)

loop until filename = ""

end sub

6樓:匿名使用者

這是我自己做的。有完整的**,可供參考。如有疑問可繼續提問。

在vb中怎麼把檔案路徑新增到list的列表裡面去 ?

7樓:匿名使用者

直接新增就行了呀!假設listbox的名稱為list1,commondialog控制項名稱為commondialog1,直接用下列語句就可以新增乙個通過commondialog選中的檔案:

if <>then

end if

vb讀取當前目錄所有txt檔案並分別按檔名存放在list1裡,單擊路徑讀取到text1裡

8樓:網友

這個**是可以的。但是你要把text1的multiline屬性設為true,否則你只能看到顯示的是一行。

如果你要顯示的類容太多,你可以吧 text的 scrollbars 屬性設為 3 - both 就是上下左右都有滾動條。

這兩個屬性是隻讀的。只有的屬性欄裡面設定。不能通過**來設定的。

9樓:網友

so easy

你是要解決思路。

還是要 exe程式。

還是要 源**。

vb 如何獲取資料夾列表,顯示在listbox中,並將資料夾名稱作為變數

10樓:網友

sub 獲得資料夾列表()

dim ff = dir("d:\aaa\", 16) '在括號內輸入你指定的目錄。

do while f <>""

if instr(f, ".") = 0 thenf

end if

f = dir ' 查詢下乙個目錄。

loopend sub

如何用dos命令,把根目錄下所有資料夾內的檔名提取出來,生

使用dos命令中的dir就可以生成這樣的文字檔案。下面介紹具體操作方法。1.以windows xp作業系統為例,單擊 開始 執行 輸入cmd,如圖1所示,然後單擊 確定 圖1 開始cmd命令 3.在命令提示符視窗中輸入以下命令,如圖2所示。dir d c filelist.txt 圖2 用此命令生成...

如何把多個資料夾放在資料夾內,如何把多個資料夾放在一個資料夾內

1 滑鼠左鍵點選不鬆後拖動,把所有需要的資料夾全部選中,按下快捷鍵 ctrl x 把這些資料夾全部剪下。2 在目的資料夾上右擊,選擇 貼上 被選中的多個資料夾進入該目的資料夾。3 同樣多次操作,可以把多個資料夾放在一個資料夾內。1.先在f盤的空白地方,點選滑鼠右鍵 新建 資料夾然後幫資料夾改個你想好...

如何把資料夾中所有檔案的檔名匯出

燕燕知識百科 需要將某資料夾下的所有檔名批量匯出時,可嘗試以下操作 step1.新建txt檔案在需要匯出檔名的那個資料夾下,新建一個txt檔案,名稱隨意。step2.輸入命令開啟新建的txt檔案,輸入 dir b files.txt 注意 在 dir 後面和 前面各有一個空格。這個命令的意思是,將資...