I want the user to locate a txt file on his computer which will later be used by my code for analysis. Is there a way to do that? One possible way is to make user enter the path of txt file. But that's not how I would prefer it Thanks
- Is that a WinForms application?Pablo Romeo– Pablo Romeo2015-05-07 19:21:52 +00:00Commented May 7, 2015 at 19:21
- Throw him a open file dialog; get the file path, store it somewhere for future use.Sriram Sakthivel– Sriram Sakthivel2015-05-07 19:23:55 +00:00Commented May 7, 2015 at 19:23
- 1OpenFileDialog did you google this at all?Jonesopolis– Jonesopolis2015-05-07 19:24:26 +00:00Commented May 7, 2015 at 19:24
- Upvote tooltip says "This question shows research effort; It is useful and clear". Upvoter please read it before upvoting :\Sriram Sakthivel– Sriram Sakthivel2015-05-07 19:26:39 +00:00Commented May 7, 2015 at 19:26
- do some research on the "Directory" class, follow this example stackoverflow.com/questions/714101/…user3477273– user34772732015-05-07 19:26:52 +00:00Commented May 7, 2015 at 19:26
| Show 1 more comment
1 Answer
string filename; var loadDialog = new OpenFileDialog { Filter = "Text File|*.txt", InitialDirectory = @"C:\Your\Start\Directory\" }; if (loadDialog.ShowDialog() == DialogResult.OK) filename = loadDialog.FileName; 1 Comment
sceiler
Make user browse and select sounds a lot like a winform with openfiledialog. He also added this information in a comment. :)