|
Adding a new key
<appSettings>
<add key="AdminUserName" value="admin"></add>
<appSettings>
Retriving the key value
System.Configuration.ConfigurationSettings.AppSettings["AdminUserName"]
Regards!
-- modified at 1:33 Tuesday 22nd November, 2005
|
|
|
|
|
To Write in coniguration File name "App1.config"
XmlTextWriter xw= new XmlTextWriter("App1.Config",null);
xw.Formatting=Formatting.Indented;
xw.WriteStartDocument();
xw.WriteStartElement("configuration");
xw.WriteStartElement("appSettings");
xw.WriteStartElement("add");
xw.WriteAttributeString("key","Name Of Key");
xw.WriteAttributeString("value","Place Actual value here");
xw.WriteFullEndElement();
xw.WriteFullEndElement();
xw.WriteFullEndElement();
//xw.WriteEndElement();
xw.Flush();
xw.Close();
to Read From file
XmlTextReader xr = new XmlTextReader("App.config");
while(xr.Read())
{
switch(xr.NodeType)
{
case XmlNodeType.Element:
Console.Out.WriteLine("Element: "+ xr.Name);
while(xr.MoveToNextAttribute())
Console.Out.WriteLine(" Attribute: ["+xr.Name+"]='"+xr.Value+"'");
break;
case XmlNodeType.DocumentType:
Console.Out.WriteLine("Document: "+xr.Value);
break;
case XmlNodeType.Comment:
Console.Out.WriteLine("Comment: "+xr.Value);
break;
}
}
to Use in Application
SetConnectionString(ConfigurationSettings.AppSettings["Name of key you want to use"]);
regards
Asad Mahmood
|
|
|
|
|
How to get the code(["SerialNumber"]) of harddisk of local area network
I know the name of computer
|
|
|
|
|
You must be an Administrator -On this computer- I think, and then do it with
The WMI SDK[^].
------------------------------ "The Soapbox has been so ..."
|
|
|
|
|
how to get XML tag of different sites for use in our sites for news reading.Concept of RSS is used here.These xml tag are used in our form which displays the updated news,\
|
|
|
|
|
|
Why does the article you link to make you think you can read passwords from AD? I couldn't find a single line where something similar is mentioned.
But apart from the article: no, you can't.
Regards,
mav
|
|
|
|
|
mav.northwind wrote: Why does the article you link to make you think you can read passwords from AD? I couldn't find a single line where something similar is mentioned.
here's eight lines:
<br />
public static DirectoryEntry GetDirectoryEntry()<br />
{<br />
DirectoryEntry de = new DirectoryEntry();<br />
de.Path = LDAP:
de.Username = @"yourdomain\sampleuser";<br />
de.Password = "samplepassword";<br />
return de;<br />
}<br />
Norman Fung
|
|
|
|
|
Let's clarify the difference between read and write:
- read: You retrieve the (yet unknown) value of the password from a source that can give you this password. AD can not.
- write: You set the value of de.Password to a known value ("samplepassword").
mav
|
|
|
|
|
Like I said, didn't have time to try out the code (repeat: "I did not try the code"). I do understand setters/getters, thanks for the patience. Basically, I was asking "You cannot read that attribute?" or "Is there another class in this/other object library from which I could perhaps read from it Hash of the password at least? or there's no way you can read passwords from AD?"
|
|
|
|
|
Hi folks,
I am kind of confused about C# def. about shallow copy. As far as I know, shallow copy points to the same memory location as the orginal, so if we make some changes to the copy, the orginal will be changed.
I did a test by doing the followings:
ArrayList a=new ArrayList();
a.Add(1);
a.Add(2);
ArrayList b=(ArrayList)a.Clone() /*C# says it will create a shallow copy here */
b.Add(3);
Now a and b are difference, I am confused here.
What am I misunderstading? And how to create a true deep and shallow copy in C#?
Thanks.
|
|
|
|
|
First, you need to understand the difference between value types and reference types.
All structures and primitives (such as int, long, float) are value types. Value types exist in the stack and are always copied. For example:
int a = 1;
int b = a;
All classes are reference types and their objects exist in the heap. Variables used to access class objects really only store addresses (so to speak) to their objects. Keyword "new" creates an object and returns a reference to that object. For example:
ArrayList a = new ArrayList();
ArrayList b = a;
Now, a shallow copy means that only an object's member variables are copied. This means the value types and references are copied, but the referenced objects themselves are not copied/cloned. A deep copy is when you clone the referenced objects too. You can do this by overriding your class' Clone() method and explicitly clone your reference member variables.
In the case of your ArrayList example, it's storing integers which are value types. So, changing the cloned ArrayList's items will not effect the original ArrayList. However, if the original ArrayList stored reference types instead, then that would be another story.
Phew! That was a bit long winded, but I hope that made sense.
|
|
|
|
|
the example you shown is shallow copy.
To achieved deep copy you need to create an object for arraylist and not a reference to it
ArrayList b = new ArrayList().
int i = 0
while (i < b.count)
{
a[i] = b[i];
i++;
}
shallow copy mean two pointers pointing at the same piece of memory.
|
|
|
|
|
hello. i have a menu, when a user clicks an item in it, the program calls a function, which calls another function based on the value of a combobox. the combobox isnt visible until the first function is called, how can i make the program 'wait' until an item is selected in the combobox? i try this, but it returns 1 right away.
while(clientlist.SelectedText == "Choose Client #")
continue;
clientlist.Visible = false;
return (System.Convert.ToInt32(clientlist.SelectedItem) + 1);
any suggestions?
thanks in advance,
sam kline
|
|
|
|
|
Correct me if wrong ;(
below is my idea....
1. set the combobox to be invisible
2. in the first func: set the combo box to be visible
3. In the event handler for the combo box, call the second func when user selects the item from the combo box
<< >>
|
|
|
|
|
HI,
Why don't you use selected item change event of the menu to show the combobox and execute the combobox selected Index change function.
regards
|
|
|
|
|
I'm trying to write a wrapper for this mfc dll to call from c# via p/invoke
Code128BarcodeToClipboard
[^]
I get the win32 error code 203: The system could not find the environment option that was entered.
Has anyone had any luck calling these methods from c#? I need to generate the barcode images(code 128) from an aspx page...any help would be appreciated.
Thanks
Graham
Graham
|
|
|
|
|
I thought there was C# code to generate bar codes on CP somewhere ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
There is...but unfortunately they aren't the type I require...i've found codabar and several others in c# but only an mfc version for the code 128.
I created an active x control wrapper for the mfc dll, but get a COMException "catastrophic error" when i try to invoke a function from c#.
I'm experienced in writing and calling native win32 dll's...but having a lot of trouble trying to use the MFC component. I can get the code to run from adding the method to the contstructor, but can't pass any parameters that way, and still get the error when i try to call a function.
I used aximp.exe to generate a slightly different interface to the component, but still get an ActiveXException when I try to invoke a member.
Graham
|
|
|
|
|
I am getting a id from a datagrid in a aspx page and then I want another page to display de pdf file file corresponding to the id, with the path in a sql2000 file. Can anyone help me.
|
|
|
|
|
Hi there,
Just open a window with the url pointing to the pdf file on ur web server, and you dont have to worry anything becoz IE will do it for u.
<< >>
|
|
|
|
|
I'm writting an app that receives and sends a data packet via TCP/IP
I'm wondering what would be the easiest way to parse out the data packet I receive, since there are no delimiters seperating the information.
Here is the break down of the data packet
four-byte start pattern
two-byte binary
20-byte fixed length
variable length data
four-byte end pattern
Thanks for your thoughts
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
It appears to me that you answered your own question.
You know that the first 4 bytes are the start pattern
You know that the next 2 bytes are binary
So on and so forth,
.....
|
|
|
|
|
okay so maybe I'm over thinking this, but I can do something like
coutn over 6 (total bytes) to the data that I'm looking for.
I guess I'm wondering is how do I tell my app to go to this spot in the data stream, and grab the data from here to there and copy it to the string variable?
Thanks
Tom Wright
tawright915@yahoo.com
|
|
|
|
|