473,320 Members | 1,744 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

multiple settings files

I have created a class library (DLL) that requires a certain XML file in the
same directory as the DLL. This XML file is essentially a configuration or
settings file but I want it to be a separate file from the standard
user.config file. My attempts to do this did not yield what I needed:

(1) I first thought of just using a separate Settings object in my project,
but I observed that that simply inserts a separate section in user.config,
not a separate file as I require.

(2) I next tried just a plain XML file that I could read/write manually. I
could then add a post-build command to copy this file to the bin directory
when I create my DLL. That's fine for building the library itself but if I
add this library into another project as a reference how could I
automatically bring the XML file along as well?

Is there a different (better?) way to do something like this?

Nov 20 '08 #1
3 3779
"michael sorens" <m_********@newsgroup.nospamwrote in message
news:F3**********************************@microsof t.com...
>I have created a class library (DLL) that requires a certain XML file in
the
same directory as the DLL. This XML file is essentially a configuration or
settings file but I want it to be a separate file from the standard
user.config file. My attempts to do this did not yield what I needed:

(1) I first thought of just using a separate Settings object in my
project,
but I observed that that simply inserts a separate section in user.config,
not a separate file as I require.

(2) I next tried just a plain XML file that I could read/write manually. I
could then add a post-build command to copy this file to the bin directory
when I create my DLL. That's fine for building the library itself but if I
add this library into another project as a reference how could I
automatically bring the XML file along as well?

Is there a different (better?) way to do something like this?

With option (2) have you tried to test the existence of the file, and if it
does not exist, simply create it with defaults? When your dll first needs
it, it could request the user to setup some settings. With this approach,
the client to your dll could either not create the file, or somehow setup
one where it installs your dll.

Nov 20 '08 #2
Hi Michael,

As for the scenario you mentioned, I think the best approach is storing the
data into the built-in configuration section(such as AppSetting or a custom
config section). Thus, you can use .NET standard configuration API to load
it.

Since you want to separate the file, you can consider Mike's suggestion
about define a internal method which can programmtically generate a default
template(of that xml file). Thus, if the target application hasn't copied
the XML file(together with the dll), your internal method will autogenerate
one. For the template xml file, you can consider storing it in
dll/assembly's embeded resource:

#Understanding Embedded Resources in Visual Studio .NET
http://www.codeproject.com/KB/dotnet...resources.aspx

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subs...#notifications.

Note: MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 2 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions. Issues of this
nature are best handled working with a dedicated Microsoft Support Engineer
by contacting Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/en-us/subs.../aa948874.aspx
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
>From: =?Utf-8?B?bWljaGFlbCBzb3JlbnM=?= <m_********@newsgroup.nospam>
Subject: multiple settings files
Date: Wed, 19 Nov 2008 19:38:00 -0800
>
I have created a class library (DLL) that requires a certain XML file in
the
>same directory as the DLL. This XML file is essentially a configuration or
settings file but I want it to be a separate file from the standard
user.config file. My attempts to do this did not yield what I needed:

(1) I first thought of just using a separate Settings object in my
project,
>but I observed that that simply inserts a separate section in user.config,
not a separate file as I require.

(2) I next tried just a plain XML file that I could read/write manually. I
could then add a post-build command to copy this file to the bin directory
when I create my DLL. That's fine for building the library itself but if I
add this library into another project as a reference how could I
automatically bring the XML file along as well?

Is there a different (better?) way to do something like this?

Nov 20 '08 #3
Thanks to your pointers I discovered that embedded resources is the key to
what I need. I added my file as a resource, then during startup I check for
its existence as a file and create the file from the resource if it is not
already there.
(I found this additional link on Adding and Editing Resources most useful:
http://msdn.microsoft.com/en-us/library/7k989cfy.aspx.)

Nov 21 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: AMT2K5 | last post by:
Hello. When I compile my program I recieve lots and lots of the following message which I am trying to decipher. "xxx was declared deprecated". What exactly does that mean?
11
by: Mike | last post by:
Looking to find any information on how to properly configure multiple instances of DB2. This is on Win2k db2 ver 7.2. I am basically looking for information on how the multiple instance settings...
2
by: SenthilVel | last post by:
HI all in my visual studio DOtnet . i am not able to open multiple cs files in the projects , its openings only one cs file at a time, can any one let me know, what setttings i must do in order...
6
by: mark | last post by:
I have an asp.net ecommerce web application on a remote web server. I'm using an Access database on the back end. I've notice a few strange things. When I mimic an multiple user environment by...
5
by: BPearson | last post by:
Hello I would like to have several sites share a single web.config file. To accomplish this, I would point the root of these sites to the same folder. Is there any reason why I might not want to...
2
by: Sean | last post by:
I have an ASP.NET web application that needs to be rolled out to a number of clients. The functionality is the same in all applications, but each client has its own database. At the moment, I...
5
by: George | last post by:
Hi, Is it possible to specify the location of a web.config file in an ASP.NET application? I have one ASP.NET application which is to be hosted on 2 web sites in the same web server. I want...
5
by: vj | last post by:
Hi all, I am using C++Builder-5. I want to run multiple cpp files at the same time. If I use the C++Builder for running a cpp file (i.e., I just double click the cpp file, it then opens in the...
0
by: Fidencio | last post by:
I have multiple projects that each have their own "My.Settings" configuration files. Is it possible to access the my.settings variables from other project's setting files? Let me give an...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.