|
OmitXmlDeclaration[^]
The code is an example. You have to be writing to the xml file somehow, so just use XmlWriter and XmlWriterSettings .
Logifusion[^]
|
|
|
|
|
Hi,
I am writing. But im more like appending from xml file to another xml file.
All i use is the WriteXml("xmlfile.xml"); method which keeps remaking the file.
If i manually remove the header, it comes back after an appending has taken place.
So basically im not using xmlwriter(settings).
Im using DataSet to do this.
So how can i prevent the header being added in the file?
|
|
|
|
|
Umm, DataSet.WriteXml is overloaded to take an XmlWriter .
DataSet ds = ...;
XmlWriterSettings xws = new XmlWriterSettings();
xws.Indent = true;
xws.IndentChars = " ";
xws.OmitXmlDeclaration = true;
XmlWriter xw = XmlWriter.Create("xmlfile.xml", xws);
ds.WriteXml(xw);
Logifusion[^]
|
|
|
|
|
Hi,
Its not adding the header anymore.
But now i get these strange characters before my root tag:
<root>
How come?
|
|
|
|
|
Not sure. My best guess is that the encoding is messed up. Try different settings for the Encoding property.
Logifusion[^]
|
|
|
|
|
Hi,
I tried: xws.Encoding = Encoding.Default;
That worked.
I thank you for your time Dustin!
|
|
|
|
|
Hi,
Is there any way in Dot Net or VC through which i could determine the IP addresses and/or Computer Names of all the computers on a local area network. Any help or link would be highly appreciated...
Regards,
Wasif Ehsan.
|
|
|
|
|
I think you might want to check out using Active Directory to retrieve info like that. Try this article[^] for example.
Josh
|
|
|
|
|
I think what Josh said is good advice.
There is another way to attack the problem, if you're interested. You could send out ARP (Address Resolution Protocol) requests to IPs on the whole network and see what responses you get. An ARP request is broadcasted to the whole network and it basically asks the question: "Who has IP address www.xxx.yyyy.zzz?". Each device on the network looks for such packets and will reply to the sender with its MAC address, which then allows the sender to associate an IP Address with a MAC address so that it knows how to get packets to that device.
For example, let us say that you are on a computer whose IP address on the LAN is 192.168.2.33. You want to know what other computers are out there, specifically on the subnet 192.168.2.x. Let us further say that there are three more machines on that subnet: 192.168.2.50, 192.168.2.67, and 192.168.2.4. Your computer sends out a whole slew of ARP requests, like this (this is what it might look like in a packet sniffer):
From: 192.168.2.33 BROADCAST --> who has 192.168.2.1 ?
From: 192.168.2.33 BROADCAST --> who has 192.168.2.2 ?
From: 192.168.2.33 BROADCAST --> who has 192.168.2.3 ?
From: 192.168.2.33 BROADCAST --> who has 192.168.2.4 ?
....
From: 192.168.2.33 BROADCAST --> who has 192.168.2.255 ? Now when those three machines see their addresses asked for, they reply to your computer like so:
From: 192.168.2.50, To: 192.168.2.33 --> 192.168.2.50 is at [some MAC Address]
From: 192.168.2.67, To: 192.168.2.33 --> 192.168.2.67 is at [some MAC Address]
From: 192.168.2.4, To: 192.168.2.33 --> 192.168.2.4 is at [some MAC Address] Now, when your computer picks those messages up, it knows how many computers are on the subnet 192.168.2.x and what their IP addresses are. From there to getting the computer names would not be hard.
This is just another idea, if you want a more low-level method of solving the problem. In order to send and receive packets from your application, doing a quick article search on CodeProject for "sending packets" or "receiving packets" should pull back some helpful results.
I hope this gives you some ideas; doubtless there are other ways of doing it, and perhaps more efficient than this one.
Sincerely,
Alexander Wiseman
|
|
|
|
|
That's very interesting. Thanks for taking the time to write it!
Josh
|
|
|
|
|
No problem. Thanks for the Active Directory link!
Sincerely,
Alexander Wiseman
|
|
|
|
|
Can anybody confirm what the correct syntax is for using the #ifdef DEBUG statement is?
I am attempting to do something like this:
private bool CheckLogon(string username, string password)
{
#ifdef DEBUG
return true;
#endif
...
snipped code that does release logon checks
...
return checkLogonResult;
}
However this gives a preprocessor directive compiler error.
According to google the syntax above is correct, so I must be committing some stupid mistake
|
|
|
|
|
use #if instead of #ifdef. #ifdef is a C++ directive, not C#.
Josh
|
|
|
|
|
The shame of it
Thanks though
|
|
|
|
|
You beat me to it
Sincerely,
Alexander Wiseman
|
|
|
|
|
|
Hi MrEyes,
If you are using C#, I think the correct way to do this is as follows:
#if _DEBUG
return true;
#endif Your Google search probably returned results which work in C++, but not in C#, unless I am mistaken.
Let me know if that works out.
Sincerely,
Alexander Wiseman
|
|
|
|
|
I need to detect type of network connection that current active on computer (including the IP Address of that connection). I have computer that have two type connection Dialup and LAN (using LAN card). Now I want to know that both connection active or not, because I meet some sample that must send WebRequest to know a network connection that exist or not.
Beside that, if we can detect the Dialup (on LAN card also). How we can know the IP address that received on Dialup, we know that Dialup use DHCP service and the IP address dynamic.
That's all. Thanks for answering.
Regrads,
Ariston Darmayuda.
Simple mind programmers, I don't need a complicated mind.
|
|
|
|
|
This is my code for drawing a set of 8 circles:
private void tbInputTest_Paint(object sender, PaintEventArgs pe)
{
//Get the Graphics object
g = pe.Graphics;
//Create an array of rectangles
Circles = new RectangleF[8];
for (int i = 0; i < 8; i++)
{
Circles[i] = new RectangleF(310, 30+(i * 40), 30, 30);
g.FillEllipse(Brushes.White, Circles[i]);
g.DrawEllipse(Pens.Black, Circles[i]);
}
}
I have a button that when pressed will update the fill color of one of the circle. how i do that? I mean how to propagate the graphic handle toward the whole program. by the way the circles appear on a tab control which make thing not that easy.
Donkaiser
|
|
|
|
|
Use the Invalide method of the control to make it redraw itself.
---
b { font-weight: normal; }
|
|
|
|
|
which invalid method? do u have an example?
Donkaiser
|
|
|
|
|
anyControl.Invalidate();
// If you need an immediate redraw...
anyControl.Update();
// Alternatively, if you're lazy and always want an immediate redraw...
anyControl.Refresh();
Josh
|
|
|
|
|
oh i see. so each time i wanna update sth i need to refresh the display. i thought the paint event keep running in the background. anyway i was trying to implement this:
button1_click(....event e)
{
g.FillEllipse(Brushes.Red, Circles[3]);
g.DrawEllipse(Pens.Black, Circles[3]);
}
g is global type Graphics;
Circles is global type RectangleF[];
but it gave me that i have invalid parameter. why? Please refer to my original code for the on paint code.
Donkaiser
|
|
|
|
|
'g' has probably been disposed of after your Paint event handler is called. Instead of caching the Graphics object you receive in the Paint handler, try calling CreateGraphics() on the TabPage in the Click handler (be sure to call Dispose on that Graphics object when you're finished with it). Draw with that Graphics object instead.
Josh
|
|
|
|
|
donkaiser wrote: i thought the paint event keep running in the background.
No, the paint event is only called when it's needed. If it was running constantly, it would use a huge amount of cpu, and the display would flicker.
---
b { font-weight: normal; }
|
|
|
|