Reading files from application path may be one of key requirement of any application. Actually we can place many place you love to have, on a installation machine there can be restriction as well.
Like wise in a Windows system, installer may want to put apps and other files to Programfiles. This folder intended to work with executable,configuration files etc. You can’t programmatically create new folder or files in Programfiles folder, which may require some admin rights. So where we kept those documents and other data ?
It is wise to store such files on Application data folder or even on your Document folder. For reports and other stuffs Document folder is enough.
Access Special Folders
We can use the Enironment.SpecialFolder to access the App data and Documents and also can fetch path to those folders using GetFolderPath method of Environment class.
datapath = Environment.GetFolderPath(Environment.SpecialFolder .ApplicationData); reportPath = Environment.GetFolderPath(Environment. SpecialFolder.MyDocuments);
the first line will get the location of C:\Users\manoj\AppData\Roaming and the second will show the Document folder path .
Access application path
How to access application/executable path in C#. This can be done using Application.ExecutablePath and the GetFolderPath method