This project is read-only.

.NET version

Jun 4, 2013 at 3:49 PM
Edited Jun 4, 2013 at 3:50 PM
Hello Author,

Do you plan on providing FtpClient which could be used with programs that are built with older .NET versions?

Some history why I am asking this :)

I have large program that consists from multiple modules built on .NET 2.0-3.5. Some modules have implemented export/import functionality using your FtpClient. FtpClientVersion is dated 8/16/2011
Configuring for new FTP connection I've ran into issue with Wing FTP server that it does not support MLST command but supports MLSD command (in response to FEAT only MLSD command is present.
I've found out that old version of FtpClient was still sending MLST commands. I've picked current version (FtpClient. and and tested with this FTP server and everything worked fine.
Now I've run into next issue - current version of FtpClient is built using .NET 4.0 features such as enum.HasFlag() and public socket.Dispose(). So I've adjusted your code to make it work with .NET 2.0. Changed everywhere where you use enum.HasFlag (btw this method is might be performance killer in some situations because of type checks and boxing-unboxing values) and made some changes in FtpSocketStream.Close() method - commented out //m_socket.Dispose();

Should I send those changes to you or...?
Jun 4, 2013 at 6:29 PM
I just wanted to let you know that I've read this and I'm going to look into it some more. I'm about to leave to go out of town so it will be a little later, just wanted to acknowledge that I've read this and I'll dig into it further.
Jun 5, 2013 at 6:14 AM
Edited Jun 5, 2013 at 6:15 AM
I've dropped all usage of Enum.HasFlag from the project in favor of bitwise anding. I haven't removed the socket.Dispose() call yet, I've got to look into that further. This should make it significantly easier to back-port the code. The Extensions namespace contains non-standard FTP features implemented as extension methods which weren't supported until 3.5 if I recall correctly so you'll probably want to exclude that code as well.
Jun 5, 2013 at 6:38 PM
Edited Jun 5, 2013 at 6:40 PM
After sleeping on this I think the best path forward here is to add something along the lines of #if !NET2 and you can define NET2 in your projects to exclude the socket dispose() calls. I'm not sure of the implications for new versions of the framework if I out right remove the call so I don' t think I will. If you run across other pieces of code that don't work in .net 2 let me know and I'll look at work-arounds using a similar fashion. I could build and test against .net 2 but I really don't need to, this is more of a "I feel your pain" change I'm willing to put in.

Here's an example of what I've added:
#if !NET2
So if you are using, for example Visual Studio, you can add NET2 to the conditional compilation symbols and the incompatible bits would be excluded from the build.
Jun 12, 2013 at 8:58 AM
Thank you alot for swift response. This is perfect resolution.
Jun 14, 2013 at 12:10 AM
I am thinking of upgrading to FtpClient. as well, but realize its not dotnet 2.0 compatible. I tried the latest commit, but see it isn't net2 compiler ready. Did I miss something, is there more work in progress, or do I need to rewrite it if I indeed need it? It seems pretty integrated with 3.5(System.Core.dll) and extensions, not clear how BangisBanginis pulled this off.
Jun 14, 2013 at 12:12 AM
Tell me what issues you're having specifically and I'll look into what needs to be done to get things moving for you.
Jun 14, 2013 at 12:18 AM
I am using vs2008, not sure if that is related. Attempting a build with 2.0 and System.Net.FtpClient.csproj gives quite a few errors. First 4 -
Error 1 The type or namespace name 'Linq' does not exist in the namespace 'System' (are you missing an assembly reference?) C:\Users\Erik\Desktop\FTPclient\System.Net.FtpClient\Extensions\GetChecksum.cs 3 14 System.Net.FtpClient
Error 2 The type or namespace name 'Linq' does not exist in the namespace 'System' (are you missing an assembly reference?) C:\Users\Erik\Desktop\FTPclient\System.Net.FtpClient\FtpExtensions.cs 3 14 System.Net.FtpClient
Error 3 Cannot define a new extension method because the compiler required type 'System.Runtime.CompilerServices.ExtensionAttribute' cannot be found. Are you missing a reference to System.Core.dll? C:\Users\Erik\Desktop\FTPclient\System.Net.FtpClient\FtpExtensions.cs 18 41 System.Net.FtpClient
Error 4 Cannot define a new extension method because the compiler required type 'System.Runtime.CompilerServices.ExtensionAttribute' cannot be found. Are you missing a reference to System.Core.dll? C:\Users\Erik\Desktop\FTPclient\System.Net.FtpClient\Extensions\XCRC.cs 20 38 System.Net.FtpClient

Others similar.
Jun 14, 2013 at 12:50 AM
Alright, I've broken down and added project that targets .net 2.0 and modified the code so it would build. I haven't tested it at all. I dealt with the extension method issue by per this stackoverflow thread. Essentially, what you need is NET2 defined and it should include and exclude what's necessary for the code to build. You'll need references to at least System and System.Web (for the static methods that accept a URI). You can alternatively include System.Net.FtpClient\System.Net.FtpClient.NET2.csproj in your project if you want to build it as a DLL. That project file is already setup for building against the 2.0 framework.
Jun 14, 2013 at 12:56 AM
You'll need to make sure FtpExtensionAttribute.cs (new file) is included in your build for the extension methods to compile.
Jun 14, 2013 at 12:58 AM
Thank you, this should help.
Jun 14, 2013 at 1:02 AM
No problem