By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,760 Members | 1,630 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,760 IT Pros & Developers. It's quick & easy.

An object reference is required for the nonstatic field, method, or property

P: n/a
I am getting the following error on "rec "

rec = TheFile1.SendCommandFile("RCVFILE " + TheArrayVal,10000000 * 10);

public int SendCommandFile(string theCommand, int timeOut)
{
rc1 = RoboFTPSession.RoboSendCommand(theCommand, timeOut * 10);
finderror(rc1);
return rc1;
}

Jan 30 '06 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Make the method static or create an instance of the class before calling the
method. Just like the error indicates.

<df********@hotmail.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
I am getting the following error on "rec "

rec = TheFile1.SendCommandFile("RCVFILE " + TheArrayVal,10000000 * 10);

public int SendCommandFile(string theCommand, int timeOut)
{
rc1 = RoboFTPSession.RoboSendCommand(theCommand, timeOut * 10);
finderror(rc1);
return rc1;
}

Jan 30 '06 #2

P: n/a
Because SendCommandFile is an instance method, you can't call it using
the class name. You have to make a particular instance of TheFile1 and
then call the method on that instance.

TheFile1 myFile = new TheFile1(... whatever arguments are required
....);
rec = myFile.SendCommandFile("RCVFILE " + TheArrayVal, 10000000 * 10);

Jan 30 '06 #3

P: n/a
I do. here is the code.....
static void Main(string[] args)
{
try
{
Utilities TheFile1 = new Utilities();
TheFile1.StartSession("xxx-FTP", 1, 0, "");
TheFile1.SendCommand("FTPLOGON \"ftp.xxxxxx.com\" /user=xxxx
/pw=xx", 10 * 10);
TheFile1.SendCommand("CD \"C:\\files\\listing\"", 100 * 10);
TheFile1.SendCommand("FTPCD \"test\"", 100 * 10);
TheFile1.SendCommand("FTPLIST \"listing of new_dir.txt\" \"*.*\"",
1000 * 10);
TheFile1.parseFile("C:/files/listing/listing of new_dir.txt");

ArrayList TheArray = TheFile1.FileNameArray;
//string TheArray = TheFile1.FileNameArray.ToString();
for(int i = 0; i< TheArray.Count; i++)
{
rec = TheFile1.SendCommandFile("RCVFILE " + TheArrayVal,10000000 *
10);
}
// TheFile1.SendCommand("RCVFILE \"*.*\" /delete", 10000000 * 10);
TheFile1.SendCommand("RCVFILE \"*.*\"", 10000000 * 10);
TheFile1.SendCommand("STOP", 10 * 10);
TheFile1.SendCommand("FTPLOGOFF", 10 * 10);
TheFile1.EndSession();

TheFile1.viewFileNames();
}
catch(Exception)
{

}
}

Jan 30 '06 #4

P: n/a
Hi,

rec = TheFile1.SendCommandFile("RCVFILE " + TheArrayVal,10000000 *
10);

where is rec declared?
What about TheArrayVal ?

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
Jan 30 '06 #5

P: n/a
On Mon, 30 Jan 2006 14:59:51 -0500, "Ignacio Machin \( .NET/ C# MVP
\)" <ignacio.machin AT dot.state.fl.us> wrote:
Hi,

rec = TheFile1.SendCommandFile("RCVFILE " + TheArrayVal,10000000 *
10);

where is rec declared?
What about TheArrayVal ?


I'll bet it's declared in the class that main is declared in. That's
a classic console app error meaning he didn't declare rec as

private static SomeObject rec;

How do I know this? I screw up and do it all the time.
;o)
Otis Mukinfus
http://www.otismukinfus.com
http://www.tomchilders.com
Jan 31 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.