|
I am trying to get each item from a listview and write it to an xml file. For instance lets say i have 2 items in the ListView: http://download.com/download1.zip & http://download.com/download2.zip. below is the code i have but it gives me an error: Unable to cast object of type 'System.Windows.Forms.ListViewItem' to type "System.String'.
XmlNode nodeDload = xmlDoc.DocumentElement;
XmlElement Dload = xmlDoc.CreateElement("Download");
XmlElement dataDload = xmlDoc.CreateElement(i.ToString());
XmlText textDload = xmlDoc.CreateTextNode("");
nodeDload.AppendChild(Dload);
foreach (string item in aUrlView.Items)
{
Dload.AppendChild(dataDload);
dataDload.AppendChild(textDload);
textDload.Value = item;
++i;
}
Example Below
<root>
<download>
<1>http://download.com/download1.zip</1>
<2>http://download.com/download2.zip</2>
</download>
</root>
Could someone help me out with this?
Thanks in advance
Don't be overcome by evil, but overcome evil with good
|
|
|
|
|
I have a program where I am importing data from a comma delimited file. The data is from years of user input that was not validated at time of input, therefore some of the data is useless. I have found my way around most of the problems except one. In this file there is a birthday for each customer. If the user inputed the date as "76/00/25", DateTime.Parse will not read it correctly. Should I put this in a try/catch block and set the data to something default ( like 1/1/1900 )?
Thanx in advance.
Jude
|
|
|
|
|
I have done a fair amount of data cleansing and what we usually do is dump the bad data into another file. Then apply human analysis to fix the solution for larger and large portions of data. Hopefully, you will then get to a relatively small set of data. For the final set make best guesses based on weighted importance of the data. (BTW, use nulls instead of defaults when you don't know. Some people born on 1/1/1900 might be offended otherwise)
A man said to the universe:
"Sir I exist!"
"However," replied the Universe, "The fact has not created in me A sense of obligation."
-- Stephen Crane
|
|
|
|
|
Thanx for the response!
Ok, I have another question.
How do I set a DateTime value to null? I tried dtDate = null, but it did not compile.
Also, I am passing this value to a stored procedure and the column can hold a null value, but will the procedure allow that...IOW does it have to be defined as so in the procedure?
Thanx again!
Jude
|
|
|
|
|
Hi i am wanting to read an xml file and load the data into various strings:
<root>
<filename>
<1>First String</1>
<2>Seconed String</2>
</filename>
<fileinfo>
<1>First String</1>
</fileinfo>
</root>
string[] fileName;
string fileInfo;
Could someone point me in the right direction?
Thanks
------------------------------------------------------
Don't be overcome by evil, but overcome evil with good
|
|
|
|
|
XmlDocument document = new XmlDocument();
//Load your xml
...
//Then use XPATH
XmlNode node = document.SelectSingleNode("/root/filename/1");
or such
A man said to the universe:
"Sir I exist!"
"However," replied the Universe, "The fact has not created in me A sense of obligation."
-- Stephen Crane
|
|
|
|
|
thanks alot!
Don't be overcome by evil, but overcome evil with good
|
|
|
|
|
And be wise enough to know the difference.
teejayem wrote:
Don't be overcome by evil, but overcome evil with good
A man said to the universe:
"Sir I exist!"
"However," replied the Universe, "The fact has not created in me A sense of obligation."
-- Stephen Crane
|
|
|
|
|
Hello.
Is possible (visual studio 2005, c#) to find hyperlinks in word (.doc) file?
TIA
Regards,
Bojan
|
|
|
|
|
i want to make a copy of one of my existing form including its design view with in that project. i am not able to copy its design view how can i do it please tell me soon.....
|
|
|
|
|
Use the filesystem and not the IDE.
A man said to the universe:
"Sir I exist!"
"However," replied the Universe, "The fact has not created in me A sense of obligation."
-- Stephen Crane
|
|
|
|
|
Hi,
I want to compare the performance of the logger with log4net, and the the enterprise logging library by Microsoft.
Can you provide me some example on "enterprise logging library by Microsoft" (framework 2.0)
Thanks !
jayasshc
|
|
|
|
|
They hide those examples in the documentation[^]
Test Drive
The Logging and Instrumentation Application Block has been developed as a result of analyzing common enterprise development challenges and successful solutions to these challenges. However, because each application is unique, you will not find this application block suitable for every application. To evaluate this application block and determine its applicability to your projects, Microsoft suggests you dedicate at least half of a day to explore the application block. The following is a suggested evaluation approach:
1. Download Enterprise Library.
2. Install Enterprise Library and compile all application blocks and tools.
3. Read the "Introduction" and "Scenarios and Goals" sections of the documentation.
4. Compile and run the QuickStart samples, and read through the related "QuickStart Walkthroughs" and "Key Scenarios" sections of the documentation.<br />
5. If the application block looks like a good fit for your application, try implementing a simple use case in your application or in a throw-away prototype application using the application block.
|
|
|
|
|
Hi,
Suppose I have a function which takes in 4 objects as parameters like:
methodA(classA obj1, classA obj2, classA obj3, classA obj4)
and inside the method, a check will be performed and depending on the result, either the first three objects will be used, or the last three.
The way I did this in C++ is basically by defining three pointers, and have those pointers point to either the first three objects or the last three depending on the check. And later those three pointers are used to access the data. But how can I achieve this in C#? Thanks a lot.
|
|
|
|
|
When you are using objects, you are actually using references to the objects. The four method parameters are references. To get another three references, you just have to declare them in the method:
classA use1, use2, use3;
if (some condition) {
use1 = obj1;
use2 = obj2;
use3 = obj3;
} else {
use1 = obj2;
use2 = obj3;
use3 = obj4;
}
|
|
|
|
|
|
I have a form with 26 textboxes on it. I need each textbox to have text that is unique from any other textbox on the form. What is an easy way to do this?
Thanks
|
|
|
|
|
Do you want to check whether the texts is unique or do you want to fill the textbox ?
|
|
|
|
|
I want to check if the text is unique from the other 25 textboxes on the form.
|
|
|
|
|
Well the simplest way I can think of off the top of my head is to put the text boxes in a List<textbox> and use nested loops like:
<br />
public bool ValidateTextBoxen()<br />
{<br />
List<TextBox> textBoxen = new List<TextBox>();<br />
<br />
textBoxen.Add(TextBox1);<br />
textBoxen.Add(TextBox2);<br />
...<br />
textBoxen.Add(TextBoxN);<br />
<br />
for(int i = 0; i < textBoxen.Count; i++)<br />
{<br />
for(int k = 0; k < textBoxen.Count; k++)<br />
{<br />
if (textBoxen[i].Text == textBoxen[k].Text && i != k )<br />
return false;<br />
}<br />
}<br />
<br />
return true<br />
}<br />
-- modified at 15:37 Tuesday 25th July, 2006
|
|
|
|
|
Dictionary<string, object> stringProbe = new Dictionary<string, object> ();
stringProbe[textBox1.Text] = null;
...
stringProbe[textBox25.Text] = null;
if (stringProbe.ContainsKey(mustBeUniqueTextBox.Text))
{
// Text is not unique
}else
{
//Text is unique
}
|
|
|
|
|
Hi Guys...
Rather urgent question...
I need to be able to browse all available windows domains on the local network, but the kicker is that I can't garentee that the machine that the app is running on is a member of any domain...?
Does anyone know of a function that can enumerate the domains available?
All the looking I've done requires you to have a domain to start with and if the machines in a work group then how can i look out from that???
|
|
|
|
|
If you could discover all the domains within a network without being part of the domain, MS would have had one MAJOR security hole sitting out there that would have killed them.
Your computer and your user must be part of a domain. From there you still will not see ALL domains. You will only see those domains that trust the domain you are a part of.
Though you should keep in mind that this is specific to the old domain model. For ActiveDirectory and a network that has eliminated the domain controllers, you would have to be part of ActiveDirectory and have the rights to query the AD tree.
|
|
|
|
|
Sorry I don't understand...
if that's the case how does windows provide you with a list of domains that you can join a machine too????
and where do the listings for work groups come from????
I suspect WINS but can't confirm this or find a way to access the information.
|
|
|
|
|
RobStroud wrote: how does windows provide you with a list of domains that you can join a machine too????
It's been many, many years since I added a machine to a domain, but I believe I had to be logged into the domain as an administrator or some other group that has the rights to do the add.
|
|
|
|