主婦と.NETと犬のぶろぐ

奥様 と プログラム と お犬様 の 楽しい日常

目次

Blog 利用状況

ニュース

書庫

日記カテゴリ

FolderBrowserDialog(System.Windows.Forms.FolderBrowserDialog)

これは何回も使った事あります。はい。
でも、いつも既定の値を忘れてしまいますのでメモっときます。

私が使う時は何故か大体いっつもこんな感じで、フォルダ指定→配下を一覧表示するのばっかりだったのですが、
(その後に、グリッドやらリストボックスやらをダブルクリックしたりして何かするとかお決まりのパターン)
一回だけフォルダ指定→配下の XML ファイルをぜーんぶ読み込むってのがありました。
まぁ、おんなじですよね。GetFiles して For Each して、読み込めばよい。

余談なんですけども、"FolderBrowserDialog クラス" で Google(日本語のページ)検索すると、msdn よりも先に どぼん!さんのページ が出るんですよねー。すごい。

■参考文献
FolderBrowserDialog コンポーネント (Windows フォーム)
FolderBrowserDialog クラス

■実行画像
起動したところ
FolderBrowserDialog 起動したところ
ShowDialog したところ
FolderBrowserDialog ShowDialog
選択されたフォルダ配下の一覧表示
FolderBrowserDialog ShowDialog

Public Class FolderBrowserDialogTest

Private Enum ColumnNames 種類 ファイル名 作成日時 更新日時 End Enum
Private Sub FolderBrowserDialogTest_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
With Me.FolderBrowserDialog1 ' 既定値に戻す .Reset() .Description = "ダイアログの上部分に出る説明" ' (既定:"") ' 頭のフォルダ System.Environment.SpecialFolder 列挙体をセットする(既定:Desktop) .RootFolder = System.Environment.SpecialFolder.Desktop ' 選択されているフォルダを指定する場合にセット。こっちは文字列。(既定:"") .SelectedPath = System.IO.Path.Combine( _ System.Environment.GetFolderPath(System.Environment.SpecialFolder.Desktop), _ "なおこ") ' 新しいフォルダボタンを表示するか否か(既定:True) .ShowNewFolderButton = True End With
With Me.TextBox1 .Text = "" .ReadOnly = True .BackColor = System.Drawing.SystemColors.Control End With
With Me.DataGridView1 .ReadOnly = True .AllowUserToAddRows = False With .Columns .Clear() .Add(ColumnNames.種類.ToString(), ColumnNames.種類.ToString()) .Add(ColumnNames.ファイル名.ToString(), ColumnNames.ファイル名.ToString()) .Add(ColumnNames.作成日時.ToString(), ColumnNames.作成日時.ToString()) .Add(ColumnNames.更新日時.ToString(), ColumnNames.更新日時.ToString()) End With With .Rows .Clear() End With End With
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If System.Windows.Forms.DialogResult.OK = _ Me.FolderBrowserDialog1.ShowDialog(Me) Then Dim selectedPath As String = Me.FolderBrowserDialog1.SelectedPath Me.TextBox1.Text = selectedPath
Me.DataGridView1.Rows.Clear() Dim dirs As String() = System.IO.Directory.GetDirectories(selectedPath) 'My だとこんな感じ 'Dim dirs As System.Collections.ObjectModel.ReadOnlyCollection(Of String) = _ 'My.Computer.FileSystem.GetDirectories(selectedPath) For Each dirPath As String In dirs Dim dirInfo As System.IO.DirectoryInfo = _ New System.IO.DirectoryInfo(dirPath) Me.DataGridView1.Rows.Add( _ "dir", _ dirInfo.Name, _ dirInfo.CreationTime.ToString("yyyy/MM/dd HH:mm:ss"), _ dirInfo.LastWriteTime.ToString("yyyy/MM/dd HH:mm:ss")) Next
Dim files As String() = System.IO.Directory.GetFiles(selectedPath) 'My だとこんな感じ 'Dim files As System.Collections.ObjectModel.ReadOnlyCollection(Of String) = _ 'My.Computer.FileSystem.GetFiles(selectedPath) For Each filePath As String In files Dim fileInfo As System.IO.FileInfo = _ New System.IO.FileInfo(filePath)
Me.DataGridView1.Rows.Add( _ "file" & Convert.ToString(IIf(fileInfo.IsReadOnly, "(読専)", "")), _ fileInfo.Name, _ fileInfo.CreationTime.ToString("yyyy/MM/dd HH:mm:ss"), _ fileInfo.LastWriteTime.ToString("yyyy/MM/dd HH:mm:ss")) Next End If ' DataGridView 列幅の自動調整 Me.DataGridView1.AutoResizeColumns(System.Windows.Forms.DataGridViewAutoSizeColumnsMode.AllCells)
End Sub End Class

投稿日時 : 2007年1月19日 12:52

Feedback

# re: FolderBrowserDialog(System.Windows.Forms.FolderBrowserDialog) 2007/01/19 15:55 えムナウ

IDataGridViewEditingControl とか
DataGridViewColumn とか
MSDNに勝っているのにびっくりしました。

# re: FolderBrowserDialog(System.Windows.Forms.FolderBrowserDialog) 2007/10/03 13:20 あきこ

こんにちは!
ePowderにお邪魔しております、あきこです。
先日、テスト用のWindowsフォームを作る必要があり、ファイルのアップロード用のダイアログはどうやって表示すればいいのか検索したところ...。

なおこさんのところにたどりつきました。
上記の内容をキーに、OpenFileDialogを使えば良いということが分り、なんとかなりました。

どうもありがとうございました!

# re: FolderBrowserDialog(System.Windows.Forms.FolderBrowserDialog) 2007/10/03 21:24 なおこ(・∀・)

>> あきこさん
お役に立てたようで何よりです。

しかし...
自分でもどんなエントリだったのかさえ忘れていましたw

# buy ivermectin nz 2021/09/28 17:38 MarvinLic

buy stromectol pills http://stromectolfive.com/# purchase stromectol online

# ivermectin usa price 2021/11/01 2:32 DelbertBup

ivermectin cream http://stromectolivermectin19.com/# buy ivermectin pills
ivermectin syrup

# ivermectin price 2021/11/01 20:33 DelbertBup

ivermectin cost http://stromectolivermectin19.online# ivermectin buy nz
ivermectin cream canada cost

# ivermectin canada 2021/11/03 0:24 DelbertBup

ivermectin generic cream http://stromectolivermectin19.online# ivermectin 90 mg
ivermectin australia

# generic ed pills from canada 2021/12/04 9:01 JamesDat

http://genericpillson.online/# cheap generic ed pills dapoxetine

# how many sildenafil 20mg can i take https://viasild24.online/
2021/12/07 19:26 Nyusjdh

how many sildenafil 20mg can i take https://viasild24.online/

# buy baricitinib https://baricitinibrx.com
buy baricitinib
2021/12/12 16:29 Buksdldj

buy baricitinib https://baricitinibrx.com
buy baricitinib

# bimatoprost generic 2021/12/13 2:19 Travislyday

http://bimatoprostrx.com/ bimatoprost generic

# bimatoprost ophthalmic solution careprost 2021/12/13 22:07 Travislyday

https://stromectols.com/ п»?order stromectol online

# ivermectin 500mg 2021/12/17 3:39 Eliastib

nocexs https://stromectolr.com stromectol cost

# stromectol cream 2021/12/17 23:07 Eliastib

prdqjt https://stromectolr.com ivermectin 6mg

# ivermectin 2mg 2021/12/18 23:54 Eliastib

qdhpqe https://stromectolr.com stromectol usa

# stromectol cost http://stromectolabc.com/
stromectol 3 mg tablet 2022/02/08 2:50 Busjdhj

stromectol cost http://stromectolabc.com/
stromectol 3 mg tablet

# ivermectin 2mg http://stromectolabc.com/
ivermectin syrup 2022/02/08 9:37 Busjdhj

ivermectin 2mg http://stromectolabc.com/
ivermectin syrup

# doxycycline 100mg dogs https://doxycyline1st.com/
where to get doxycycline 2022/02/26 20:07 Doxycycline

doxycycline 100mg dogs https://doxycyline1st.com/
where to get doxycycline

# finasteride medication https://finasteridemen.com/
2022/05/11 23:52 Finasteride

finasteride medication https://finasteridemen.com/

# ed pill https://erectionpills.best/
buy ed pills 2022/06/28 19:55 ErectionPills

ed pill https://erectionpills.best/
buy ed pills

# prescription meds without the prescriptions https://pillswithoutprescription.xyz/
online prescription for ed meds 2022/10/01 19:36 CanadaPharm

prescription meds without the prescriptions https://pillswithoutprescription.xyz/
online prescription for ed meds

# cheapest ed pills online https://erectiledysfunctionpills.shop/ 2022/10/14 22:49 Erectile

cheapest ed pills online https://erectiledysfunctionpills.shop/

# prednisone 10 mg price https://prednisone20mg.icu/ 2022/10/15 13:22 Prednisone

prednisone 10 mg price https://prednisone20mg.icu/

# online websites https://datingtopreview.com/
free dating chatting online 2022/10/17 20:38 Dating

online websites https://datingtopreview.com/
free dating chatting online

# personal ads free https://topdatingsites.fun/
free web date site 2022/11/15 0:28 DatingTop

personal ads free https://topdatingsites.fun/
free web date site

# can i buy prednisone online without prescription https://prednisonepills.site/
how to buy prednisone 2022/11/28 23:53 Prednisone

can i buy prednisone online without prescription https://prednisonepills.site/
how to buy prednisone

# online singles https://datingsiteonline.site/
datinghotlot 2022/12/05 23:49 Tading

online singles https://datingsiteonline.site/
datinghotlot

# meet me now dating site https://datingonlinehot.com/
dating free site 2022/12/09 19:21 Dating

meet me now dating site https://datingonlinehot.com/
dating free site

# Read now. Best and news about drug.
https://edonlinefast.com
Drug information. Actual trends of drug. 2023/02/16 17:50 EdPills

Read now. Best and news about drug.
https://edonlinefast.com
Drug information. Actual trends of drug.

# doors2.txt;1 2023/03/14 17:02 uMboTOPTWhFqugQHf

doors2.txt;1

# canadian pharmaceutical ordering https://pillswithoutprescription.pro/# 2023/05/14 22:14 PillsPresc

canadian pharmaceutical ordering https://pillswithoutprescription.pro/#

# paxlovid covid 2023/08/24 15:40 Davidvat

https://ed-pills.men/# best ed pills

# buy cytotec in usa 2023/08/27 15:59 Georgejep

http://misoprostol.guru/# п»?cytotec pills online

# farmacia online miglior prezzo 2023/09/24 23:34 Archieonelf

http://farmaciabarata.pro/# farmacia barata

# migliori farmacie online 2023 2023/09/27 1:19 Archieonelf

http://farmaciabarata.pro/# farmacia barata

# lana rhoades solo - https://lanarhoades.pro/ lana rhoades boyfriend
2024/03/06 16:23 LanaRho

lana rhoades solo - https://lanarhoades.pro/ lana rhoades boyfriend

# eva elfie hd https://evaelfie.site/ eva elfie photo
2024/03/07 4:39 EvaElfie

eva elfie hd https://evaelfie.site/ eva elfie photo

# aviator online https://aviatormocambique.site aviator
2024/03/11 23:24 AviatorMaz

aviator online https://aviatormocambique.site aviator

タイトル
名前
Url
コメント