+1 vote
by (170 points)
edited

Hello Team,

I am facing one issue when I upload/download file from one specific FTP. i.e, At the time of uploading/downloading it is throwing an exception. Using FileZilla also is throwing the same exception. But when we connect the same with command prompt and execute Put and Get commands in command prompt, it is working fine (uploading/downloading works fine). In our application we have integrated our FTPs with Rebex. We need to upload/download using Rebex only. So please help me how can I execute DOS FTP commands using Rebex.

Regards Naga Suresh D

Applies to: Rebex FTP/SSL

2 Answers

0 votes
by (58.9k points)
edited

Hello,

if you are using the advanced Upload / Download methods, please use the PutFile / GetFile variants instead. They are much simpler and they correspond to the commandline Put and Get commands. The Upload / Download methods were designed to do multi-file operations and they put some preconditions on the server (for instance UNIX-like system), so they are not suitable in all cases.

So please run the following code and let us know whether it helped:

Ftp ftp = new Ftp();
try
{
    ftp.Connect("server");
    ftp.Login("username", "password");
    ftp.PutFile(@"C:\MyData\file.txt", "file.txt");
    ftp.GetFile(@"C:\MyData\downloaded.txt", "file.txt");
    ftp.Disconnect();
}
catch(FtpException ex)
{
    Console.WriteLine(ex.ToString());
}
finally
{
    ftp.Dispose();
}

If you still get an exception, please send the content of ex.ToString() back to us. Thank you!

0 votes
by (170 points)
edited

Hello Team,

Thanks for your reply. Actually for download a file from FTP, I am using the same code ('GetFile') which you have suggested me in the above reply like the below code.

Ftp ftp = new Ftp();
try
{
    ftp.Connect("server");
    ftp.Login("username", "password");
    ftp.GetFile(@"C:\MyData\downloaded.txt", "file.txt");
    ftp.Disconnect();
}
catch(FtpException ex)
{
    Console.WriteLine(ex.ToString());
}
finally
{
    ftp.Dispose();
}

The above "GetFile" method is working fine for regular FTPs. But our client given us the below command to download the file from their FTP. The command is working fine in MS-DOS prompt and we can download the file. But without using the command we can't download the file using our Rebex mehtods (GetFile).

Command

ftp> Get "$$ ID=EPNY36 BID='CC7890' PASSWORD=XYZ" "your\path\filename"

Please help me to execute above command using Rebex components.

And one more doubt is : Can we have COM components in our Rebex dlls?

Thanks & Regards

Naga Suresh D

by (58.9k points)
edited

To the second question about COM components - I am not sure I understand your requirement. Do you want to reference dll's for .NET (i.e. Rebex) and COM components from the same Visual Studio project?

by (170 points)
edited

Hello Team,

What I mean for the second question is, can we use the same Rebex dlls in Legacy Foxpro projects ??

Thanks & Regards Naga Suresh D

by (58.9k points)
edited

Hello,

1 writing

ftp.GetFile("$$ ID=EPNY36 BID='CC7890' PASSWORD=XYZ", "yourpathfilename");

should do the trick. Please let us know if it helped.

2 No Rebex dll's cannot be directly used in Legacy Foxpro projects, you would have to write a simple COM wrapper (in .NET), which would expose the methods you will need. Here is a Microsoft how-to.

by (170 points)
edited

Hello Tomas,

Thanks for your help. It is working fine. I am able to download the file using above command.

Thanks & Regards Naga Suresh D

...