We help IT Professionals succeed at work.

How to Open a File Without Prompting User in Same Directory With C# Windows Form Application

thenthorn1010
on
I am attempting to open a file within the same directory as my main project, and I was wondering if someone could tell me the syntax for opening a simple *.txt file that is within the same working directory as your Windows form executable file. I am attempting to open the file without having the user have to select a file to preload a set of values into memory. Any help that you could provide with this question would be greatly appreciated.
Comment
Watch Question

Senior .Net Consultant
CERTIFIED EXPERT
Top Expert 2016
Commented:
Éric MoreauSenior .Net Consultant
CERTIFIED EXPERT
Top Expert 2016
Commented:
and the current folder can be retrieved using StartupPath (http://msdn.microsoft.com/en-us/library/system.windows.forms.application.startuppath.aspx)

and finally path.combine is useful to combine a path and a filename: http://msdn.microsoft.com/en-us/library/fyy7a5kt(v=vs.71).aspx

Explore More ContentExplore courses, solutions, and other research materials related to this topic.