No.1ベストアンサー
- 回答日時:
Directoryクラスを使ってフォルダー名やファイル名を取得しましょう
Function GetFileNameOrSubFolderName( sPath as String) as String()
dim sNames as String() = Directory.GetFiles( sPath )
dim sFolders as String() = DIrectory.GetDirectories( sPath )
dim Results as String()
ReDim Results( sNames.Length + sFolders.Length -1 )
dim n as Integer
for n = 0 to sNames.Lenth -1
Resules( n ) = sName(n)
next
' フォルダー名の前後に[]を追加
for n = 0 to sFolders.Length - 1
Results( sName.Length + n ) = "[" & sFolders(n) & "]"
next
return Results
End Function
といった具合で取得して
ListBox1.Items.Clear()
for each ss as string in GetFileNameOrSubFolderName( "C:\Work" )
ListBox1.Items.add( ss )
next
といった具合でリストボックスなどに反映しましょう
# エラー処理などをしていませんので適宜修正してください
お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!
関連するカテゴリからQ&Aを探す
おすすめ情報
- ・漫画をレンタルでお得に読める!
- ・人生のプチ美学を教えてください!!
- ・10秒目をつむったら…
- ・あなたの習慣について教えてください!!
- ・牛、豚、鶏、どれか一つ食べられなくなるとしたら?
- ・【大喜利】【投稿~9/18】 おとぎ話『桃太郎』の知られざるエピソード
- ・街中で見かけて「グッときた人」の思い出
- ・「一気に最後まで読んだ」本、教えて下さい!
- ・幼稚園時代「何組」でしたか?
- ・激凹みから立ち直る方法
- ・1つだけ過去を変えられるとしたら?
- ・【あるあるbot連動企画】あるあるbotに投稿したけど採用されなかったあるある募集
- ・【あるあるbot連動企画】フォロワー20万人のアカウントであなたのあるあるを披露してみませんか?
- ・映画のエンドロール観る派?観ない派?
- ・海外旅行から帰ってきたら、まず何を食べる?
- ・誕生日にもらった意外なもの
- ・天使と悪魔選手権
- ・ちょっと先の未来クイズ第2問
- ・【大喜利】【投稿~9/7】 ロボットの住む世界で流行ってる罰ゲームとは?
- ・推しミネラルウォーターはありますか?
- ・都道府県穴埋めゲーム
- ・この人頭いいなと思ったエピソード
- ・準・究極の選択
デイリーランキングこのカテゴリの人気デイリーQ&Aランキング
-
リストビューの列ヘッダーの幅...
-
エクセルVBAでテキストボッ...
-
レコードセットにnullの場合
-
TextBoxの内容を右寄せ
-
VB.NETでのイベントの途中終了
-
定数を構造体で・・・
-
Excel VBAでsub,dimは何の略?
-
texで図と表を並べたい
-
subsequentとnextの違いってな...
-
コンボボックスからテキストボ...
-
演奏記号の・・・・
-
ExcelのVBAで文章にある複数の...
-
他のフォームから別のフォーム...
-
【HTML、VBScript】HTAアプリケ...
-
C#のループでtextboxに値を入れ...
-
テキストボックスに大文字を
-
comboboxのクリックイベントに...
-
変数の宣言はすべきでしょうか...
-
【VBS】クリップボード操作につ...
-
プロシージャまたは関数の引数...
マンスリーランキングこのカテゴリの人気マンスリーQ&Aランキング
-
リストビューの列ヘッダーの幅...
-
構造体のコピー
-
共有フォルダの「共有のアクセ...
-
VBAとVB6.0とC#の速度比較
-
零元のはいっている
-
<python> グローバル変数とロ...
-
VB.netである関数を呼んで、そ...
-
W1、W2<=R^nをそれぞれ同時連立...
-
C言語で10行10列の行列式の値を...
-
文字列の中からある文字の個数...
-
VBA public変数はどのようなこ...
-
VBAでcallで呼び出したsubを終...
-
他のフォームから別のフォーム...
-
アクセスできない保護レベルエ...
-
エクセルVBAでテキストボッ...
-
C言語のサフィックスについて
-
VB.NETでのイベントの途中終了
-
Excel VBAでsub,dimは何の略?
-
【VB6.0】 あるフォームから他...
-
タイムアウトする仕組みを作りたい
おすすめ情報