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.Va lidatorUpg.Comp areXMLFiles(str ing, string, System.Xml.XmlD ocument, System.Xml.XmlD ocument)' 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 1665 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.ex e "Validator_EN_O LD.xml","Valida tor_EN.xml"
I am getting an IndexoutofRange exception .
Please help ASAP.
class ValidatorUpg
{
static void Main(String[] args)
{
Console.WriteLi ne("{0}:{1}", args[0], args[1]);
Console.ReadLin e();
XmlDocument Source = new XmlDocument();
XmlDocument Target = new XmlDocument();
ConfigManager cm = new ConfigManager() ;
string fPath = (cm.DataFileLoc s.BinDirectory. EndsWith("\\")) ? cm.DataFileLocs .BinDirectory : cm.DataFileLocs .BinDirectory + "\\";
string fFileName = Path.Combine(cm .DataFileLocs.B inDirectory, args[1].ToString());
if (File.Exists(fF ileName))
{
string nFileName = (cm.DataFileLoc s.EditDirectory .EndsWith("\\") ) ? cm.DataFileLocs .EditDirectory : cm.DataFileLocs .EditDirectory + "\\";
string oFileName = Path.Combine(cm .DataFileLocs.E ditDirectory, args[0].ToString());
// File.Move(fFile Name, oFileName);
MessageBox.Show (args[0].ToString(), args[1].ToString());
Source.Load(oFi leName);
// This is the point where the new file can be installed on to the Bin Folder
Target.Load(fFi leName);
ValidatorUpg Upgrade = new ValidatorUpg();
ValidatorUpg.Co mpareXMLFiles(o FileName, fFileName, Source, Target);
}
else
{
//CONTINUE WITH INSTALLATI N
}
}
public static void CompareXMLFiles (string oFileName,strin g fFileName,XmlDo cument Source,XmlDocum ent Target)
{
foreach (XmlNode ChNode1 in Source.FirstChi ld.ChildNodes)
{
//use below if codition if u need to check the sub nodes
if (ChNode1.HasChi ldNodes == true)
{
foreach (XmlNode ChNode in ChNode1.ChildNo des)
{
//CreatePath(ChNo de);
CompareLower(Ch Node, oFileName, fFileName, Target);
}
}
CompareLower(Ch Node1, oFileName, fFileName, Target);
}
}
public static void CompareLower(Xm lNode 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.WriteLI ne
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.ex e "Validator_EN_O LD.xml" "Validator_EN.x ml"
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_O LD.xml,Validato r_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)VA LUES('"&amount& "','"&date1&"') "
2. sql2="Insert Into '"+cust_name+"' (credit_balance ,credit_date)VA LUES('"&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)VA LUES('"&amount& "','"&date1&"') "
2. sql2="Insert Into '"+cust_name+"' (credit_balance ,credit_date)VA LUES('"&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.ex e C:\Validator_EN _OLD.xml C:\Validator_EN .xml ---- Works fine
But when i change to the path to anything else like
ValidatorUpg.ex e 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 ???
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 webserver runs that part of the
script (see attached file, snippet.php), though, it doesn't go through.
I don't get an error message or anything...it just returns a "1"
(whereas it should return a "0") as far as I can tell. I have read the
PHP...
|
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 that he can do command-line
stuff with 4.1.0.
Is anyone else using the command-line executable with a version earlier than
4.3.0?
Thanks!
|
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 (!feof($p2))
print fgets($p2);
|
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 argument to the process.
When I try this from a Windows application it works fine, however, when I do
this from my web application I get errors.
Both applications are running under the same users so am not sure if it is a
permissions problem.
...
|
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
need to do, I get blocks of errors like:
root@slackserve:/var/www/htdocs# php ./phptest.php
PHP Warning: Unknown(): Unable to load dynamic library
'/usr/lib/php/extensions/mysql.so' - libmysqlclient.so.14: cannot open
shared object file: No such...
| |
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 included and made
sure it's in the path. I have read on the forums that some have fixed
the problem by telling GCC to link math libraries if it's not done by
default.
So, using gcc -lm helped to resolve the problems with defining the
|
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 (STARTDATE, ENDDATE DATE) RETURNS INTEGER
DETERMINISTIC NO EXTERNAL ACTION
BEGIN ATOMIC
DECLARE DAYCOUNT INTEGER
|
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 done for resolving that error.
I am trying to execute one particular command function when the commandis pressed.Likewise, I have 100 commands and whenever the commands are pressed the corresponding function + arguements should be passed and the...
|
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 Command Prompt or
Browser or some other application?
Ojas.
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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 then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |