0
Reply

Console App

Reetu

Reetu

Mar 6 2006 1:32 PM
2k
Hi,
I want to display  an xml content on the command prompt screen, if a user puts in a /xml OR 'Nothing was entered' if the user hasnt input in anything.
For that, I have written this code, but weirdly, the xml content only shows whereas the "nothing was entered' doesnt show.

ANy ideas ?

using System;

using System.Xml;

namespace TestUtility

{

/// <summary>

/// Summary description for Class1.

/// </summary>

class EntryPoint

{

/// <summary>

/// The main entry point for the application.

/// </summary>

[STAThread]

static void Main(string[] args)

{

string[] argss = new string[10];

argss[0] = "/xml";

argss[1] =@"C:\Test\SystemSetting.xml";

if( argss.Length >0)

{

if(argss.GetValue(0).ToString()== "/xml")

{

Execute_Cmd_xml(argss);

}

else

{

Console.WriteLine("Unrecognised command");

Console.ReadLine();

}

}

}// end of main

static void Execute_Cmd_xml(string[] args)

{

Console.WriteLine(args.ToString());

string sIFolderName ="";

try

{

XmlDocument doc = new XmlDocument();

if (args.Length > 1)

{

for(int i=1; i < args.Length; i++)

sIFolderName = sIFolderName + " " + args.GetValue(i);

sIFolderName = sIFolderName.TrimStart();

Console.WriteLine(sIFolderName);

doc.Load(sIFolderName);

Console.Write(doc.OuterXml);

Console.ReadLine();

}// end if

}

catch(XmlException xmlEx)

{

Console.WriteLine("Failed to load " + sIFolderName, xmlEx.Message);

}

}

}

}