2016-07-26 10 views
1

現在、私はWPF Appでこれを使用しています。OpenFileDialogのパスを変更する

private void buttonPresentations_Click(object sender, EventArgs e) 
     { 
      openFileDialogPresentations.ShowDialog(); 
     } 

私は最後のパスを記憶していますが、今度はそれをセットパスに変更したいと思います。 私は3つのラジオボタンを持っており、各ラジオボタンは別のパスにつながるはずですので、openFileDialogに渡す変数でそれを行うことを考えましたが、どうすればよいか分かりません。誰もこれをして、私にそれのリードを与えることができますか?

+2

あなたdesidered初期パス – Steve

+0

・ホープ[ハードドライブ上の位置決めファイル]にInitialDirectoryプロパティを設定します(http://stackoverflow.com/a/38580437/3796048)役立つかもしれませんあなた –

答えて

3

ダイアログに表示されるコード内のフォルダにIntitialDirectoryを設定できます。

private void buttonPresentations_Click(object sender, EventArgs e) 
{ 
    openFileDialogPresentations.IntitialDirectory = youFolderPath; 
    openFileDialogPresentations.ShowDialog(); 
} 
+0

えええええええええええええええええええええええええええええええええええええええええええええええええええええええええええええええええええええええええ、 – BlackPanic

+0

@BlackPanicこれをマーキングするか、あるいは最も受け入れられた答えとしてあなたを助けた答えを検討してください。 – Mafii

0

標準のファイルダイアログは、ダイアログが開くフォルダいる決定InitialDirectory性質を持っています。

private void buttonPresentations_Click(object sender, EventArgs e) 
{ 
    openFileDialogPresentations.InitialDirectory = @"X:\Data\Presentations"; 
    openFileDialogPresentations.ShowDialog(); 
} 
0

これは、InitialDirectoryプロパティを使用して行うことができます。あなたは、ラジオボタンのための3つの異なるパスを設定することができます

private void button1_Click(object sender, EventArgs e) 
     { 
      OpenFileDialog dialog = new OpenFileDialog(); 
      [email protected]"D:\MyDir"; 
      dialog.ShowDialog(); 
     }