|
I want to store an array of values in the app.config file. I basically want the program to delete a bunch of files based on what is in there.
How do I do that?
Thanks,
Jim
|
|
|
|
|
You can store related lists of values in the config file and access them using a section handler provided by the framework, or you can roll your own section handler (provided it implements IConfigurationSectionHandler ). In the following example, I used System.Configuration.NameValueSectionHandler to retrieve a list of strings from a custom configuration block:
App.config file:
=================
<?xml version="1.0" encoding="utf-8" ?><br />
<configuration><br />
<configSections><br />
<section name="simpsons" type="System.Configuration.NameValueSectionHandler" /><br />
</configSections><br />
<br />
<simpsons><br />
<add key="father" value="Homer" /><br />
<add key="mother" value="Marge" /><br />
<add key="son" value="Bart" /><br />
<add key="olderDaughter" value="Lisa" /><br />
<add key="youngerDaughter" value="Maggie" /><br />
</simpsons><br />
</configuration>
Application (just a simple console app):
========================================
using System;<br />
using System.Collections;<br />
using System.Collections.Specialized;<br />
using System.Configuration;<br />
<br />
namespace SectionHandlerSample<br />
{<br />
class Class1<br />
{<br />
[STAThread]<br />
static void Main(string[] args)<br />
{<br />
NameValueCollection values = (NameValueCollection)ConfigurationSettings.GetConfig("simpsons");<br />
foreach(string key in values.Keys)<br />
{<br />
Console.WriteLine("Key='{0}' and value='{1}'", key, values[key]);<br />
}<br />
Console.ReadLine();<br />
}<br />
}<br />
}
I would recommend reading a bit more about this topic in online help for the System.Configuration namespace. There are several out of the box handlers available, as well as a full description of the IConfigurationSectionHandler and an explanation of configuration groups as well.
Hope this helps.
The most exciting phrase to hear in science, the one that heralds the most discoveries, is not 'Eureka!' ('I found it!') but 'That's funny...’
|
|
|
|
|
Hi,
I have built a sample visual c# project.
I want to know
1.Its output file name
2.Its dependent libraries.
How/where can i find these in my solution.
Thanks
Vinay.
|
|
|
|
|
I assume you are using Visual Studio .NET. If that's true, you can right click on the Project, click Properties. A dialog box will show the output file among other things. For dependent libraries, open the References tree node within Solution Explorer.
Regards
Senthil
|
|
|
|
|
Thanks for the information.
How to add a new dependent?
|
|
|
|
|
Right click on the project in Solution Explorer, choose Add->References.
Regards
Senthil
|
|
|
|
|
in Visual C++ 6.0, I can add dependencies by mentioning lib filename under linker options or I can directly edit .mak file. Is there any equivalent way in vc#
Thanks
Vinay.
|
|
|
|
|
The command line compiler accepts a /Reference =[^] switch for specifying assemblies that are needed. see also the /lib[^] switch for specifying which directories to search in addition to the standard places
Anger is the most impotent of passions. It effects nothing it goes about, and hurts the one who is possessed by it more than the one against whom it is directed.
Carl Sandburg
|
|
|
|
|
what might be file extensions for assemblies.
Does the assembly contain MSIL or native code? or it can be MSIL/native?
Thanks
Vinay.
|
|
|
|
|
An assembly is most often a dll (system.dll, system.data.dll,windows.forms.dll are examples - most of the framework is in dlls whose name is the same as the namespace), but could be an exe. Usually they are MSIL. If they are native code, then normally a type library (.tlb) is required...
you can find much more detailed information here.[^]
Anger is the most impotent of passions. It effects nothing it goes about, and hurts the one who is possessed by it more than the one against whom it is directed.
Carl Sandburg
|
|
|
|
|
|
|
|
Congratulations! You successfuly clicked the Submit button! Celebrate! Have a
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I want to use the Windows .NET DataGrid to display items in a collection. This is quite easy
dataGrid1.DataSource = myCollection;
BUT the columns appear in an arbitary order (not as declared in the item class).
Is there anyway to specify the order that public properties of a class are read by the data binding mechanism of the datagrid. I know that gridcolumnstyles can be used but only where tables are used.
Any clues would be gratefully appreciated.
|
|
|
|
|
I've used this approach many times
DataGridTableStyle gridStyle = new DataGridTableStyle();<br />
gridStyle.ReadOnly = true;<br />
gridStyle.MappingName = myCollection.GetType().Name;<br />
<br />
<br />
DataGridTextBoxColumn cs = new DataGridTextBoxColumn();<br />
cs.MappingName = "VehicleID";
cs.HeaderText = "Vehicle ID";
cs.Alignment = HorizontalAlignment.Center;<br />
cs.Width = 80;<br />
cs.TextBox.Enabled = false;<br />
gridStyle.GridColumnStyles.Add(cs);<br />
<br />
<br />
dataGrid1.TableStyles.Add(gridStyle);<br />
<br />
the column order will follow the order in which the DataGridTextboxColumns are added to the gridstyle.
|
|
|
|
|
Hello all,
I am interested in parsing a cascading style sheet for selector strings and their associated declaration property/value pairs in order to create a dictionary of key=selector : value=declaration dictionary. Anyone able to help with the C# regular expression statements in .NET that would identify these elements of a style sheet or know of a decent resource where I might find more information on this subject? TIA for your assistance! I really appreciate it.
|
|
|
|
|
You might try using a tool such as The Regulator[^] to help you with this, they also have a search built in so you can see if someone else has already done this.
|
|
|
|
|
Thanks for your help, Nick. I appreciate it.
|
|
|
|
|
Hello,
I am looking for a way to get the html source of some frame in an AxWebBrowser control. All my attemps were unsuccessfull :/
All solutions are welcome even if they dont use AxWebBrowser.
Regards.
|
|
|
|
|
Add a reference to MSHTML.tlb, then you can use a IHTMLDocument2 against the browsers Document property which will give you all sorts of information. A quick example:
private void button2_Click(object sender, System.EventArgs e)
{
IHTMLDocument2 doc = (IHTMLDocument2)this.browser.Document;
if(doc != null)
this.txtOut.Text = doc.body.outerHTML;
}
|
|
|
|
|
True,
That gives the main document html source, but NOT the inner frames sources.
Moreover i dont find anything about .frames propertie of IHTMLDocument2.
Regards,
fdb.
|
|
|
|
|
fickdb wrote:
Moreover i dont find anything about .frames propertie of IHTMLDocument2.
Where did you look? I found the IHTMLDocument2::frames[^], which can give you a IHTMLFramesCollection2[^]. When you iterate over those items you can query for a IHTMLWindow2[^] which also has a reference to the frames IHTMLDocument2 .
|
|
|
|
|
Ok that finaly works.
Thx for pointing me again on the right things.
Regards.
|
|
|
|
|
Hi
I used NetApi32.dll; NetUserEnum() to retreive the users from Domain.
NetworkAPI.NetUserEnum(strDomain, 0, 2, out bufPtr, -1, out EntriesRead, out TotalEntries, out Resume);
The above one is working fine if I have one server.
But if I have One Domain and in that Two or more Servers, then when I gave domain name and try to retreive the users from domain it is returning only one server users. Why?
When I try to add the users to a folder/file from windows explorer when I select the domain name it is displaying the users from both the servers.
How can I overcome this problem?
Thanks in Advance.
Amar
|
|
|
|