Hi,
I have project (*.dll) that should read paths as string from external file.
Only requiriment is that it have to be in external file that can be modified by user before he runs this application.
I dont't know where to start.
I tried to use app.confing from project settings that writes desired values to xml file but no success yet (probably need to study this more).
Is this the right approach for what I am trying to do? Or is there any other way?
Many thanks,
Peter
In general, I have a form with listbox that lists all the *.dwg files in particular folder. But the path may be different depending on PC where application (*.dll) is installed just something like "C:\mylistboxfiles" or D:\mylistboxfiles" etc.. I just would need allow the user to change this path whenewer he needs and make my application more flexible.
So I was looking on the internet what options do I have and found that XML app.config may be a solution to store this information and read it by applicaton.
E.g. this does not work and seems returns nothing form xml.
this is in my class in project;
Dim dbPath As String = ConfigurationSettings.AppSettings("mypath")
and this is in xml;
<?xml version="1.0" encoding="utf-8" ?> <configuration> <appSettings> <add key="mypath" value="c:\mylistboxfiles" /> </appSettings> </configuration>
I was expecting that I can read the settings and allow to user change the path from here .
I can create e.g. text (*.txt) file and read the values from there but I was looking for some more suitable solution and newer method for this so that's why I asked what are the options for how to read settings from external file like this.
I did not explain all the details for the first time, I know, sorry for that.
Regards,
Peter
you can have a look on below link, which might be useful for you.
http://www.vbforums.com/showthread.php?679107-VS-2010-app-config
http://forums.asp.net/t/1168194.aspx?how+to+use+app+config+in+a+console+application
I am going to put here my two pennies worth. To solve your issue I would just create a setting variable for storing the path, this will be stored on the app.config file. You can access it calling My.Settings.(Variable Name) and save it by calling My.Settings.Save() method. I will set a default value of say None. On the application before using the path I would check that the value is set to a valid system folder, if the value is not set then I would prompt the user to set it. Hope it helps
My $0.02 CAN,
App.config for class libraries (.dll) is not the same as for .exe. I found that the settings I was creating and trying to use ended up in acad.exe.config (the host). When I found this out I started using txt files instead.
I'll throw out another option used by many programs for storing paths: registry keys. Relatively easy to manipulate from multiple sources, and already includes separate locations for per-computer/per-user settings.
Many thanks for your answers guys, it helped me. I've decided to use this part of code. It is something else what I asked for but good enough for now.
Dim mycurrentpath As String = My.Application.Info.DirectoryPath
It takes the current path of loaded *.dll and by this I can get the current path from any place of my application.
I checked for articles and solutions you've sent so next time I will know what options do I have.
Peter