0

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

6
  • Is that a WinForms application? Commented May 7, 2015 at 19:21
  • Throw him a open file dialog; get the file path, store it somewhere for future use. Commented May 7, 2015 at 19:23
  • 1
    OpenFileDialog did you google this at all? Commented 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 :\ Commented May 7, 2015 at 19:26
  • do some research on the "Directory" class, follow this example stackoverflow.com/questions/714101/… Commented May 7, 2015 at 19:26

1 Answer 1

1
string filename; var loadDialog = new OpenFileDialog { Filter = "Text File|*.txt", InitialDirectory = @"C:\Your\Start\Directory\" }; if (loadDialog.ShowDialog() == DialogResult.OK) filename = loadDialog.FileName; 
Sign up to request clarification or add additional context in comments.

1 Comment

Make user browse and select sounds a lot like a winform with openfiledialog. He also added this information in a comment. :)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.