B
Bill Cohagan
I'm writing a console app in c# and am encountering a strange problem. I'm
trying to use redirection of the standard input stream to read input from a
(xml) file. The following code snippet is from this app:
===============================
static void Main(string[] args)
{
if (args.Length > 0) Console.SetIn(new StreamReader(args[0]));
//executes if I don't use the "<", ">" redirection syntax when invoking
XmlTextReader xmlin = new XmlTextReader(Console.In);
xmlin.WhitespaceHandling = WhitespaceHandling.None;
if (args.Length > 1) Console.SetOut(new
StreamWriter(args[1]));//executes if I don't use the "<", ">" redirection
syntax when invoking
XmlTextWriter xmlw = new XmlTextWriter(Console.Out);
string SchemaResource = "DBDumper.DumpSpec0.xsd";
XmlValidatingReader xmlvr = new XmlValidatingReader(xmlin);
Assembly a = Assembly.GetExecutingAssembly();
Debug.Assert (a.GetManifestResourceInfo(SchemaResource) != null);
XmlTextReader xsdreader = new XmlTextReader(new
StreamReader(a.GetManifestResourceStream(SchemaResource)));
xmlvr.Schemas.Add(null, xsdreader);
try
{
xmlvr.Read();
....
=============================
So, assuming my app's executable is foo.exe, things work fine if I type in
foo input.xml output.xml
Also,
foo input.xml > output.xml
works fine. But, if I type in:
foo < input.xml > output.xml
I get an error on the xmlvr.Read() in the last line above, complaining that
the stream does not support a Write!!
Can anyone give me help on this? I've stared at it now for a while and don't
see the problem.
Thanks in advance,
Bill
trying to use redirection of the standard input stream to read input from a
(xml) file. The following code snippet is from this app:
===============================
static void Main(string[] args)
{
if (args.Length > 0) Console.SetIn(new StreamReader(args[0]));
//executes if I don't use the "<", ">" redirection syntax when invoking
XmlTextReader xmlin = new XmlTextReader(Console.In);
xmlin.WhitespaceHandling = WhitespaceHandling.None;
if (args.Length > 1) Console.SetOut(new
StreamWriter(args[1]));//executes if I don't use the "<", ">" redirection
syntax when invoking
XmlTextWriter xmlw = new XmlTextWriter(Console.Out);
string SchemaResource = "DBDumper.DumpSpec0.xsd";
XmlValidatingReader xmlvr = new XmlValidatingReader(xmlin);
Assembly a = Assembly.GetExecutingAssembly();
Debug.Assert (a.GetManifestResourceInfo(SchemaResource) != null);
XmlTextReader xsdreader = new XmlTextReader(new
StreamReader(a.GetManifestResourceStream(SchemaResource)));
xmlvr.Schemas.Add(null, xsdreader);
try
{
xmlvr.Read();
....
=============================
So, assuming my app's executable is foo.exe, things work fine if I type in
foo input.xml output.xml
Also,
foo input.xml > output.xml
works fine. But, if I type in:
foo < input.xml > output.xml
I get an error on the xmlvr.Read() in the last line above, complaining that
the stream does not support a Write!!
Can anyone give me help on this? I've stared at it now for a while and don't
see the problem.
Thanks in advance,
Bill