Hi,
I had a function to compare two XML files within a project . Now I need to change that into a commandline exe in such a way that it whouls accept two params from the Command line. I have changed it .. but I am getting some errorr
ValidatorUpg.ValidatorUpg.CompareXMLFiles(string, string, System.Xml.XmlDocument, System.Xml.XmlDocument)' cannot be accessed with an instance reference; qualify it with a type name instead
Error 10 Cannot create an instance of the static ValidatorUpg.cs
Error 9 Cannot declare variable of static type ValidatorUpg.cs - namespace ValidatorUpg
-
{
-
static class ValidatorUpg
-
-
{
-
static void Main(string[] args)
-
{
-
if (args.Length == 0)
-
{
-
-
return;
-
}
-
else
-
{
-
ValidatorUpg upgrade = new ValidatorUpg();
-
Console.WriteLine("Hai");
-
string oFileName = args[0];
-
string fFileName = args[1];
-
//XmlDocument Source;
-
// XmlDocument Target;
-
XmlDocument Source = new XmlDocument();
-
XmlDocument Target = new XmlDocument();
-
Source.Load(oFileName);
-
Target.Load(fFileName);
-
string rootSource = Source.FirstChild.Name.ToString();
-
upgrade.CompareXMLFiles(args[0],args[1],Source,Target);
-
-
}
-
}
-
-
public static void CompareXMLFiles(string oFileName,string fFileName,XmlDocument Source,XmlDocument Target)
-
{
-
foreach (XmlNode ChNode1 in Source.FirstChild.ChildNodes)
-
{
-
//use below if codition if u need to check the sub nodes
-
if (ChNode1.HasChildNodes == true)
-
{
-
foreach (XmlNode ChNode in ChNode1.ChildNodes)
-
{
-
//CreatePath(ChNode);
-
CompareLower(ChNode, oFileName, fFileName, Target);
-
}
-
}
-
CompareLower(ChNode1, oFileName, fFileName, Target);
-
}
-
}
-
-
public static void CompareLower(XmlNode NodeName, string oFileName, string fFileName, XmlDocument Target)
-
{
-
Boolean flag = false; // node is there
-
string Path = CreatePath(NodeName);
-
XmlNodeList selectnodeslist = Target.SelectNodes(Path);
-
if (selectnodeslist.Count == 0)
-
{
-
insertNode(NodeName, fFileName, Target);
-
}
-
else
-
{
-
foreach (XmlNode selectnode in selectnodeslist)
-
{
-
-
----------------
-
-------------
-
if (flag == false)
-
{
-
insertNode(NodeName, fFileName, Target);
-
-
-
-------------------
-
---------------------
-
}
-
}
-
}
-
public static void insertNode(XmlNode Node, string fFile,XmlDocument Target)
-
{
-
-------------
-
}
-
public static string CreatePath(XmlNode Node)
-
{
-
-----------
-
}
-
}
-
}
14 1641 Plater 7,872
Recognized Expert Expert
Well these two are easy.
Error 10 Cannot create an instance of the static ValidatorUpg.cs
Error 9 Cannot declare variable of static type ValidatorUpg.cs
You have static classes and you are trying to instanciate them. Static classes to not get instanciated, which means no constructor references (that would be the myclass a = new myclass() stuff)
The same thing applies to the first error, you are trying to use a static class with an instance when you need to use it as a type
I am still getting an error ... in the command line ....
I am giving the cmd line as
ValidatorUpg.exe "Validator_EN_OLD.xml","Validator_EN.xml"
I am getting an IndexoutofRange exception .
Please help ASAP.
class ValidatorUpg
{
static void Main(String[] args)
{
Console.WriteLine("{0}:{1}", args[0], args[1]);
Console.ReadLine();
XmlDocument Source = new XmlDocument();
XmlDocument Target = new XmlDocument();
ConfigManager cm = new ConfigManager();
string fPath = (cm.DataFileLocs.BinDirectory.EndsWith("\\")) ? cm.DataFileLocs.BinDirectory : cm.DataFileLocs.BinDirectory + "\\";
string fFileName = Path.Combine(cm.DataFileLocs.BinDirectory, args[1].ToString());
if (File.Exists(fFileName))
{
string nFileName = (cm.DataFileLocs.EditDirectory.EndsWith("\\")) ? cm.DataFileLocs.EditDirectory : cm.DataFileLocs.EditDirectory + "\\";
string oFileName = Path.Combine(cm.DataFileLocs.EditDirectory, args[0].ToString());
// File.Move(fFileName, oFileName);
MessageBox.Show(args[0].ToString(), args[1].ToString());
Source.Load(oFileName);
// This is the point where the new file can be installed on to the Bin Folder
Target.Load(fFileName);
ValidatorUpg Upgrade = new ValidatorUpg();
ValidatorUpg.CompareXMLFiles(oFileName, fFileName, Source, Target);
}
else
{
//CONTINUE WITH INSTALLATI N
}
}
public static void CompareXMLFiles(string oFileName,string fFileName,XmlDocument Source,XmlDocument Target)
{
foreach (XmlNode ChNode1 in Source.FirstChild.ChildNodes)
{
//use below if codition if u need to check the sub nodes
if (ChNode1.HasChildNodes == true)
{
foreach (XmlNode ChNode in ChNode1.ChildNodes)
{
//CreatePath(ChNode);
CompareLower(ChNode, oFileName, fFileName, Target);
}
}
CompareLower(ChNode1, oFileName, fFileName, Target);
}
}
public static void CompareLower(XmlNode NodeName, string oFileName, string fFileName, XmlDocument Target)
{
}
Plater 7,872
Recognized Expert Expert
Well where is the error occuring?
Have you debugged your application?
remove the "," from your param list...
I am getting an error right at the first line
Console.WriteLIne
And that's caused because of the "," in your command line... as I stated previously. Remove the "," from your command line so that it reads
ValidatorUpg.exe "Validator_EN_OLD.xml" "Validator_EN.xml"
Your application is reading the command line args all in as one string... so it's failing because Args[1] doesn't exist.
Args[0] = "Validator_EN_OLD.xml,Validator_EN.xml"
Args has a length of 1...
and that's what's causing your problem...
I have a problem In ASP code. While I am using a variable as a table name in ASP with MS Access Database. I did try, but I didn’t get success.
Dim cust_name
cust_name=(any table name)
1. sql2="Insert Into '"&cust_name&"'(credit_balance,credit_date)VALUES( '"&amount&"','"&date1&"')"
2. sql2="Insert Into '"+cust_name+"'(credit_balance,credit_date)VALUES( '"&amount&"','"&date1&"')"
( Where cust_name is a variable. It is being used as a Table name. But these quiries are not working. Please any body give me help…… or correct Ans……..
Error: Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
[Microsoft][ODBC Microsoft Access Driver] Syntax error in query. Incomplete query clause.
/anoop_tyre/cash_insert.asp, line 19
I have a problem In ASP code. While I am using a variable as a table name in ASP with MS Access Database. I did try, but I didn’t get success.
Dim cust_name
cust_name=(any table name)
1. sql2="Insert Into '"&cust_name&"'(credit_balance,credit_date)VALUES( '"&amount&"','"&date1&"')"
2. sql2="Insert Into '"+cust_name+"'(credit_balance,credit_date)VALUES( '"&amount&"','"&date1&"')"
( Where cust_name is a variable. It is being used as a Table name. But these quiries are not working. Please any body give me help…… or correct Ans……..
Error: Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
[Microsoft][ODBC Microsoft Access Driver] Syntax error in query. Incomplete query clause.
/anoop_tyre/cash_insert.asp, line 19
Start your own thread. Hijacking someone's thread is considered rude.
Hi ,
I have an exe to which 2 arguments are to be passeed.. where both the arguments are two file paths to xml files which are to be compared.
It works fine when i put the two xml files in teh C:\ and execute but when its changes to any other dir like documents and settinsg etcetce it doesnt work.
ValidatorUpg.exe C:\Validator_EN_OLD.xml C:\Validator_EN.xml ---- Works fine
But when i change to the path to anything else like
ValidatorUpg.exe C:\Documents and settings\All users\Validator_EN_OLD.xml C:\Documents and settings\All Users\Validator_EN.xml
its is not working .. and to my surprise its not even entering the loop which runs when the args.Length ==2...
Any suggestions ???
Try putting quotes around your paths...spaces can screw up the command line. -
ValidatorUpg.exe "C:\Documents and settings\All users\Validator_EN_OLD.xml" "C:\Documents and settings\All Users\Validator_EN.xml"
Something like that.
Thanks a lot it works.. but itss really surprising that for the C: it works and for any other it doesnt ....
Thanks
Notice that in the c:\ you don't have any spaces in the path name.
This is a double post... and has already been answered...
http://bytes.com/forum/thread854813.html
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Penn Markham |
last post by:
Hello all,
I am writing a script where I need to use the system() function to call
htpasswd. I can do this just fine on the command line...works great
(see attached file, test.php). When my...
|
by: Ever Olano |
last post by:
Hi. In the docs, it says the command-line executable (that allows you to
run PHP scripts on your console as opposed to inside the web server) was
introduced in 4.3.0. But I was told by someone...
|
by: yawnmoth |
last post by:
say i have the following two php scripts:
ptest.php:
<?
$p1 = popen("c:\\php\\php -q hello.php","r");
$p2 = popen("c:\\php\\php -q hello.php","r");
while (!feof($p1))
print fgets($p1);
while...
|
by: Mandy |
last post by:
I have a command line tool that I would like to run from my .NET web
application using System.Diagnostics.ProcessStartInfo. I run cmd.exe with
this and then pass the command to run the tool as an...
|
by: news |
last post by:
I just upgraded to PHP 4.4.2 on my Slackware 10.2 system. And
Apache/mySQL/PHP all work great through a browser. No errors.
But when I try to run a PHP script through the command line, which I...
| |
by: bobrics |
last post by:
Hi,
I have been trying to compile some source code that is supposed to be
working and getting some compilation errors. The errors are with
sqrt(), log() and round() functions. I have math.h...
|
by: Ian Mackenzie |
last post by:
Hi Guys
I am VERY new to DB2 and have created a workingdays function to return
the working days between 2 dates, but I get some compiler errors when
running it:
CREATE FUNCTION WORKINGDAYS...
|
by: sowmi |
last post by:
Hi All,
I am trying to implement the concept of function pointer in C++.
While compiling i got some errors which I couldnt figure out the reason .
So,Please let me know what changes should be...
|
by: Ojas |
last post by:
Hi!,
I just out of curiosity want to know how top detect the client side
application under which the script is getting run. I mean to ask the
how to know whether the script is running under...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |