Get application path in c. Please Sign up or sign in to vote. See more: C. Hi, I want to get my application path after I install it, by C code.
How can I get that? Should I use registry key? Updated 4-Sep pm Prerak Patel. Add a Solution. Thanks all, but none of these solutions solved my problem. I found the code,i used registry: using Microsoft. Michi Elsno Dec pm. A little late but hey. I'm working on a Windows CE. NET CF2. CodeBase; MessageBox. Show adres ;. Top Rated Most Recent. Accept Solution Reject Solution. ExecutablePath What is the best way depending on the situation?
Improve this question. Peter Mortensen Leo Vo Leo Vo 9, 9 9 gold badges 54 54 silver badges 77 77 bronze badges. Why we have a lot ways to get application' path. I think there is a reason for each way.
There is a error in 6: should read: System. CodeBase , System. ExecutablePath — BillW. MapPath logic in my IoC loaded library which is not web-specific in nature — bkwdesign.
We now have the reliable IHostEnvironment. ContentRootPath , accessed through an injected IHostEnvironment dependency which contains other useful things.
There is also Process. Show 1 more comment. Active Oldest Votes. Improve this answer. Joe Joe k 27 27 gold badges silver badges bronze badges. When testing in Windows XP 32bit, it returns where the shortcut started.
Be aware that this returns a path with a backslash at the end. This caused me problems when formatting a string with the result to pass as a process argument. Combine instead. This will take care of the trailing backslash for you. Show 5 more comments. CodeBase will get you location where.
Hope this saves you some time. Matas Vaitkevicius Matas Vaitkevicius Fairly sure wanting the "current folder" is only relevant for non-web apps anyway This is the answer. Add a comment. In some cases, they can return the same value, but be careful, their purposes are different: Application. StartupPath returns the StartupPath parameter can be set when run the application System. GetCurrentDirectory returns the current directory, which may or may not be the folder where the application is located.
Further reading may be here. Home Blog How to get the current executable's path in C Code sample. Combine strWorkPath, "Settings. Recent posts. Double dot.. You can also use Path. Thanks by the way, I didn't know that.
Show 10 more comments. Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password. Post as a guest Name.
Email Required, but never shown. The Overflow Blog. Podcast Making Agile work for data science. Stack Gives Back Featured on Meta. New post summary designs on greatest hits now, everywhere else eventually.
0コメント