I found this code to show up a “file browse” dialog from C#:
OpenFileDialog ofd = new OpenFileDialog(); DialogResult b = ofd.ShowDialog(); if (b == DialogResult.OK) { CopySourceFiles.Text = ofd.FileName; }
The problem was that it was giving an error saying that DialogResult did not have a member named OK. So I had to fully qualify DialogResult as the following snippet shows:
OpenFileDialog ofd = new OpenFileDialog(); System.Windows.Forms.DialogResult b = ofd.ShowDialog(); if (b == System.Windows.Forms.DialogResult.OK) { CopySourceFiles.Text = ofd.FileName; }
Comments