Sprache: C#
Open File Dialog mit Filter
string Pfad = string.Empty;
OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
if(openFileDialog1.ShowDialog() == DialogResult.OK)
Pfad = openFileDialog1.FileName;
string Pfad = string.Empty;
OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
if(openFileDialog1.ShowDialog() == DialogResult.OK)
Pfad = openFileDialog1.FileName;
Alte URL:
/snippet/open-file-dialog/15
bitte zuerst mit new erstellen 😉
@ Xqgene, stimmt. Das kommt davon, wenn man schnell was posten will und die Funktion zu testen.
Ich würde das eher mit using machen.
Xqgene hat es schon gesagt:
Use of unassigned local variable ‚openFileDialog‘
Ich habe den Code berichtigt.