Click here to Skip to main content
15,891,704 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am writing an application using C# and XAML that needs to access FTP functions. Most, but not all, are provided by FtpWebRequestMethods.Ftp class. What is missing is the ability to execute commands on the remote server.

This functionality is available in MFC using the CFtpConnection Class.

I get options in Visual Studio to create an MFC DLL or a CLR (Common Language Runtime) DLL, but I can't see how I can combine both. I need it to be CLR, I believe, since the application is written in C#.

Is this possible to achieve? If so, how?

What I have tried:

I think the solution is to use the CLR DLL option but I can't seem to get the code to compile when I add the CFtpConnection statement and add the <afxinet.h> header include necessary.
Posted
Updated 9-Feb-18 4:44am
Comments
KarstenK 9-Feb-18 10:52am    
Tip from a seasoned programmer: avoid the MFC and use C# whenever possible. The MFC is an old and not well maintained class library, which need a lot of care to heal its problems.
Elgin76 9-Feb-18 11:13am    
I agree with the sentiment about avoiding MFC, but I need the function that was there in MFC that Microsoft hasn't provided in C# as far as I can tell.
Richard Deeming 9-Feb-18 10:52am    
Try a .NET FTP library like FluentFTP[^].
Elgin76 9-Feb-18 11:19am    
FluentFTP looked good but only for CHMOD. We need other commands to be run also; including some where we pipe the output to a file and then use FTP to read that file back into the application.

1 solution

There is no need to use MFC from C#. Here's a link that describes the FtpWebRequest object.

MSDN Docs for FtpWebRequest
[^]

Furthermore, there are numerous C# FTP classes, many of which are posted as articles right here on CodeProject.

EDIT=================================

Look at this Q/A response. It might help.

use of MFC C Dll in C#[^]
 
Share this answer
 
v3
Comments
Elgin76 9-Feb-18 11:10am    
As far as I can see that has no means by which I can execute a command on the FTP server once I have uploaded the file to it. The application has options that allow the sender to specify the parameters for a chmod command that needs to be executed on the uploaded file.
#realJSOP 11-Feb-18 10:06am    
You need to write code to do that, or find a class written around the FtpWebRequest object. I stated as much in my answer.
#realJSOP 12-Feb-18 5:30am    
I updated my answer with a link to another CP answer.
Elgin76 13-Feb-18 6:27am    
Many thanks John. I will take a look at that.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900