|
1. Don't multiple post.
2. What are you smoking?
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Hi All,
I am sure the solution to this is *Really* easy, but i've been staring at it for a while now and have got nowhere. I've written the test below in both C# and VB and both do the same thing.
I need to use an XmlReader object to read in an xml document. Note that it is essential that i use an XmlReader object as I need to perform schema validation. The code below does not incluse schema validation as as this stage i'm just trying to get an xml file into an XmlReader.
Looking in the msdn and a range of examples in google i should be able to get an XmlReader object containing my xml document by using XmlReader.Create(TextReader o). Everything is working right up until that step, but using the debug tools my XmlReader object appears to remain content-less. Here's the code:
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using System.IO;
namespace XmlTest
{
class Program
{
static void Main(string[] args)
{
String file = "C:\\WINDOWS\\Microsoft.NET\\Framework\\v2.0.50727\\CONFIG\\web.config";
XmlDocument doc = new XmlDocument();
doc.Load(new System.IO.StreamReader(file));
String docString = doc.OuterXml;
TextReader tr = new StringReader(docString);
XmlReader xr = XmlReader.Create(tr);
System.Console.ReadKey();
}
}
}
So we're loading in an xml file, putting it into an XmlDocument and getting the Xml as a string out of it. This is because ultimately when i slot this work back into what i'm doing i'll be obtaining the xml document via a string.
A TextReader object is then created from the string via a StringReader. If i debug the code i can see the document correctly loaded into the TextReader (tr) in it's entirity. It just doesn't seem to be converted into an XmlReader object via XmlReader.Create(tr).
Similarly, if i replace XmlReader.Create(tr) with XmlReader.Create(new System.IO.StreamReader(file)) I have the same problem, proving it's none of the logic inbetween that is messing things up.
What am i missing about XmlReader? Please help if you can, this is driving me absolutely nuts. When i look at it in debug the object has a depth of zero and looking in items i see "In order to evaluate an indexed property, the property must be qualified and the arguments must be explicitly supplied by the user." I have no idea what this means and google doesn't help.
You should be able to copy and paste the code and replicate the issue easily.
Many thanks,
Rolf
|
|
|
|
|
It's morning, but, try use some method of XmlReader starting with "Read"
"Throughout human history, we have been dependent on machines to survive. Fate, it seems, is not without a sense of irony. " - Morpheus
"Real men use mspaint for writing code and notepad for designing graphics." - Anna-Jayne Metcalfe
|
|
|
|
|
Tried that.
Using the ReadInnerXml and ReadOuterXml i get nothing.
Interestingly if i pass the XmlReader to an XmlDocument.load method and then inspect the XmlDocument, i see my xml is in there. But why can't i see it in the XmlReader object anywhere? Using both read methods and inspecting the object via 'watch' yields nothing.
|
|
|
|
|
Rolf Baxter wrote: Using the ReadInnerXml and ReadOuterXml i get nothing.
But these read content of current node. To move on node, use Read() method. Check out example[^].
"Throughout human history, we have been dependent on machines to survive. Fate, it seems, is not without a sense of irony. " - Morpheus
"Real men use mspaint for writing code and notepad for designing graphics." - Anna-Jayne Metcalfe
|
|
|
|
|
Hi,
Its awesome really fantastic but it would be much better if we hide all the replies of a perticular query until one clicks on the respective query (as of tree view model) and at a time one can able to view only one replay, is it possible to view other replies opend at a time and more over if i click on the parent query then all the opend childs should be closed.
Please suggest me some ideas to implement the changes
very urgent ....
santy
|
|
|
|
|
s a n t o s h wrote: Its awesome really fantastic but...
What is?
|
|
|
|
|
blackjack2150 wrote: s a n t o s h wrote:
Its awesome really fantastic but...
What is
I'm glad it wasn't just me who was thinking that.
|
|
|
|
|
Hope to use C# for ActiveX in Excel VBA. Success to call as COM, but fail to add the control from "Control Toolbox" as ActiveX
I want to use C# for ActiveX in Excel, but fail to add the control from "Control Toolbox".
I have write a COM object using C#, and I can call those function in Excel VBA normally.
But when I try to change it as a ActiveX, I fail.
The Excel can detect my COM object as a ActiveX, that means it can show in the "Control Toolbox".
Once I select it, and try to put it in the Excel, it show me a dialog box said "Cannot insert object".
I have read the following link about the error message, but for my ActiveX in C# do not have the .odl file.
http://support.microsoft.com/default.aspx/kb/171280/
Can any one give me some hints?
|
|
|
|
|
Hi.
My app can be started with different command line parameters. Some of these may represent date values. So what I do is convert the string taken from the command line into a DateTime object using the Convert.ToDateTime() method.
What format should the string resemble in order to be sure that the conversion is ALWAYS possible and successful REGARDLESS of the local/language settings of the machine that runs the program?
Thank you.
|
|
|
|
|
blackjack2150 wrote: What format should the string resemble in order to be sure that the conversion is ALWAYS possible and successful REGARDLESS of the local/language settings of the machine that runs the program?
You can pass IFormatProvider as second argument of Convert.ToDateTime . Convert will then parse string according to that format, regardless of local settings.
"Throughout human history, we have been dependent on machines to survive. Fate, it seems, is not without a sense of irony. " - Morpheus
"Real men use mspaint for writing code and notepad for designing graphics." - Anna-Jayne Metcalfe
|
|
|
|
|
By telling the user what format to use
Some examples from DOS:
XCOPY
/D:m-d-y Copies files changed on or after the specified date.
SCHTASKS /CREATE
/SD startdate Specifies the first date on which the
task runs. The format is
"yyyy/mm/dd".
And of course you should require an ISO 8601-compliant format, like "YYYY-MM-DD".
|
|
|
|
|
blackjack2150 wrote: What format should the string resemble in order to be sure that the conversion is ALWAYS possible and successful REGARDLESS of the local/language settings of the machine that runs the program
You would want to use one of the ISO 8601 formats. If you just need the date portion it should be YYYY-MM-DD or YYYYMMDD . If you need the time portion as well it should be YYYY-MM-DDTHH:MM:SS or YYYYMMDDTHHMMSS (where T is the literal character "T").
-----------------------------
In just two days, tomorrow will be yesterday.
|
|
|
|
|
Dear Gurus,
Does enyone know how I can set Image dynamically to my Button Background and delete that image from my PC?
I use Image.FromFile(@"C:\myImage.png") in my
When I try to delete image Error message apears "File used by another programm".
Thanks.
Vas
|
|
|
|
|
Opening an image from a file, locks the file. If you copy that image to a new image, dispose of the old one, then you can delete it.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Thank you for your answer.
but I wanted to know is there another way without copying file.
I'll try to describe my situation. I have created application which downloads Button Images form the remote server and shows to the Users. when Application tries to download the Image which already downloaded I wont to ovverride it but error occures.
|
|
|
|
|
Try something like this:
Bitmap BMP = new Bitmap(@"C:\myImage.png");<br />
Bitmap BMP2 = BMP;<br />
<br />
button1.BackgroundImage = BMP2;<br />
<br />
BMP.Dispose();<br />
System.IO.File.Delete(@"C:\myImage.png");
|
|
|
|
|
Thank you for your answer.
but I wanted to know is there another way without copying file.
I'll try to describe my situation. I have created application which downloads Button Images form the remote server and shows to the Users. when Application tries to download the Image which already downloaded I wont to ovverride it but error occures.
|
|
|
|
|
Hi
I want to know how to make mouse pointer visible within a windows form only.
Since iam working on a windows application, in that I should not allow mouse pointer to be visible when the mouse pointer comes outside the form.
Thanks in Advance For Ur Help
|
|
|
|
|
What's with the flood of non descriptive headers tonight ? Everyone on this forum is asking for help in some regard, probably about C#.
You can capture the mouse, and as it moves out of your form area, you can set the cursor to be null.
Seems nasty to me, tho.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I am retriving Date from SqlServer 2005 but i gets date and time instead that i want only date how should i do it?
|
|
|
|
|
First, C# is not a useful header, imagine if everyone put C#, the forum would look a little silly, right ?
There is no Date type in C#, only DateTime. You can ignore the time, if you want to.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
MyDateTime.Date will return a new object with the time element reset to midnight.
|
|
|
|
|
you can also format the date
Datetime datetime=Person.subscribedate;
datetime.tostring("d");
|
|
|
|
|
you should return only date from sql
you can use convert function
forexample
convert(datecolumn,varchar,101)
it'll only return date not time
|
|
|
|