port from vb6 to c# - WeOnlyDo Discussion board

port from vb6 to c# (wodFtpDLX / wodFtpDLX.NET)

by Rien van Ham, Thursday, December 10, 2015, 19:30 (3271 days ago)

Dear all,

I'm quite new to c# and I'm trying to port a very old application from vb6 to c#. Off course all new code is build from the ground up (based on the vb-code).

I'm getting stuck with a piece of code to connect a certificate to the sftp-object.

Some code:

if (moFTP.State == wodFtpDLXComLib.StatesEnum.Connected) { moFTP.Disconnect(); }
moFTP.Hostname = Bron.IpAdres;
moFTP.ProxyHostname = "";
moFTP.ProxyPort = 1080;
moFTP.ProxyType = 0;
moFTP.Timeout = 600;
moFTP.Passive = false;
moFTP.TransferMode = 0;
moFTP.Compression = 6;
moFTP.Blocking = true;
moFTP.Login = "";
moFTP.Password = "";

WODCERTMNGLib.Certificate certificaat = new WODCERTMNGLib.Certificate();
certificaat.LoadKey(certificatenDirectory + Bron.Certificaat);
moFTP.Certificate = certificaat; <<----- ERROR!!


Error:
Cannot implicity convert type WODCERTMNGLib.Certificate to WodFtpDlxComLib.ICertificate.....


What do I have to do?

Thanks in advance!

Rien.

port from vb6 to c#

by Jasmine, Thursday, December 10, 2015, 19:39 (3271 days ago) @ Rien van Ham

Hi Rien.

You can simply cast one object type to another, like this:

moFTP.Certificate = (wodFtpDLXComLib.ICertificate)certificaat;

I hope this helps!
Jasmine.

port from vb6 to c#

by Rien van Ham, Friday, December 11, 2015, 09:00 (3270 days ago) @ Jasmine

Hello Jasmine,

OMG, so simple...

Thank you very much, it works!

Kind regards,
Rien.