I have written a C program for saving and reading PDF files. The program saves the output files to the local computer's bin folder.
I want my program to access files from a different computer. I have heard about keeping a file path stored in the app. You can then read the app settings stored there using the ConfigurationManager class. You'll have to add a reference to System.
Configuration in your project, and reference it in the code. After that, your path can be read by accessing ConfigurationManager. AppSettings["Path"] - it will be a string. As stated in the answer above, you add a key value to app. How are we doing? Please help us improve Stack Overflow. Take our short survey. Stack Overflow for Teams — Collaborate and share knowledge with a private group.
Create a free Team What is Teams? Copy Code. Add a Solution. Get "def" ;. Get "abc" ;. Suvendu Shekhar Giri May am. Can you please share the specific section of the app.
Get "def" ; then how i i identity data when i run this application. Top Rated Most Recent. Accept Solution Reject Solution. Posted May pm Garth J Lancaster. As others pointed out in comments, you have just to duplicate the code that already handles the "abc" case, or , better, write a method having a string as parameter, e. Posted May pm CPallini. Garth J Lancaster May am. NET 2. Ask a question. Quick access. Search related threads.
Remove From My Forums. Answered by:. Excellent find for me! With this, I can override select keys in AppSettings as shown at weblogs. It seems that's that is the way it is. Visual Studio If you are having this issue with Web. Config the accepted answer is correct but just to expand since this had me giving myself the face-palm: When you add a.
Thus, when you have a config section defined in Web. Serexx Serexx 1, 1 1 gold badge 14 14 silver badges 30 30 bronze badges. Richard Richard k 21 21 gold badges silver badges bronze badges.
This requires that the entire config file be loaded. The whole config is loaded by the normal static properties anyway so this makes no real difference. Also, you could just use your own XML format and add its name to the applications' configuration files and read it directly. You will need admin privileges to do this: mklink ConnectionStrings. Scott Scott 4 4 silver badges 7 7 bronze badges. It's an option but I don't want need the settings available to other applications on the machine.
Worry is the connection strings, they have pretty generic names which may conflict with other applications. I had quite a struggle with this issue, but I found a good solution for it here: test run with external config You can direct the test run to copy files and directories into the test run directory by editing the.
Then in ExternalFile. And then from the project that needs to use the connection string, do this: If it's a Console project or Unit Test project: In Console or Unit Test projects, do this in app.
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. Stack Gives Back Safety in numbers: crowdsourcing data on nefarious IP addresses. Featured on Meta. New post summary designs on greatest hits now, everywhere else eventually.
0コメント