-
November 12th, 2005, 06:07 AM
#1
The path of a file using openFileDialog
I know it's quite a noob question but, how can I, using an openFileDialog, saving the path of the file in a string called etPath?
This is my part of the code:
Code:
public void etButtonBrowse_Click(object sender, System.EventArgs e)
{
etBrowseFileDialog.ShowDialog();
string etPath;
etPath = etBrowseFileDialog.FileName;
}
I know that the last part (etPath = etBrowseFileDialog.FileName;) isn't correct.
etButtonBrowse is the button which opens the FileDialog called "etBrowseFileDialog".
Thanks!
Last edited by StevDevil; November 12th, 2005 at 06:09 AM.
-
November 12th, 2005, 10:15 AM
#2
Re: The path of a file using openFileDialog
Why doesn't this work?
Code:
using (OpenFileDialog ofd = new OpenFileDialog())
{
if (ofd.ShowDialog() == DialogResult.OK)
{
string etPath = ofd.FileName;
}
}
Jason Isom
.NET 2.0 / VS2005 Developer
-
November 12th, 2005, 02:15 PM
#3
Re: The path of a file using openFileDialog
as Jason has mentioned so that way you can access, make sure you check for ok condition and then assign the filename.
paresh
- Software Architect
-
November 13th, 2005, 03:41 PM
#4
Re: The path of a file using openFileDialog
OK Thanks guys problem's solved!
Last edited by StevDevil; November 13th, 2005 at 03:48 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|