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

  • Thread starter Thread starter dfetrow410
  • Start date Start date
D

dfetrow410

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;
}
 
Make the method static or create an instance of the class before calling the
method. Just like the error indicates.
 
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);
 
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)
{

}


}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top