First time poster (and newbie).
I’ve created a C# winform application.
I’ve added a “Documents” folder in which I’ve added 5 PDF files.
From within my Form1, I’ve added a button and inside the button click event, I’m trying to get the files from that “Documents” folder.
I’ve googled around and found stuff like this:
string[] arr = Directory.GetFiles(string path);
But I do not wish to “hardcode” the path of my “Documents” folder.
I’d like to know if there’s a way (more dynamic) to obtain the path of my “Documents” folder.
I’ve also found these:
string path1 = Path.GetDirectoryName(Application.ExecutablePath);
string path2 = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
But they always bring me to my \bin\Debug folder.
I’ll take all the help I can get!
Thanks!
Environment.SpecialFolder enumeration you mean?
Or am I misreading the question?EDIT
I guess I did misread, my apologies. Try this:
This is also assuming you’re including the items from the “documents” folder as resources so the executable will be able to see them.