Jump to content


Photo

Corrupt File Download - WinXP SP2 - C#


  • Please log in to reply
1 reply to this topic

#1 deeshubby

deeshubby
  • Members
  • 3 posts

Posted 09 November 2006 - 05:33 PM

I've had great success integrating this library with my custom Windows Forms C# app.

When I use the sample provided for my "Download" routine, the error code seems to indicate success. When I go to open the actual file, I see it has been corrupted. Not sure what I'm doing wrong.

I've only tested GIF/JPEG images, thus far, which is the main file types my app will be throwing around. But, I may also incorporate Windows media formats in the future (.wmv, .wma, .. etc..)

Here's an example image that looks great on the server (uploaded successfully using this library, even)
Posted Image

Here's that same image after I have downloaded to my PC using the library (and then re-uploaded to the server for you to see on this post)
Posted Image

Furthermore, here's a code-snippet of how I am initializing my library object:


public SmartFTP(string hostAddress, int port, string username, string password, bool passive, bool requiresProxyAuth, string proxyHost)
{
			// Load License Key
			sfFTPLib.Global global = new sfFTPLib.Global();
			
			if(global.LoadLicenseKeyData(LICENSE_KEY))
				LogStatus("License key embedded in DLL verified.");
			else
				LogStatus("Failed to verify license key in: " + LICENSE_KEY);

			// Create our COM object through the Interop (Early Binding)
			_ftp = new FTPConnectionMTAClass();
		
			// host settings
			_ftp.Host = hostAddress;
			_ftp.Port = port;
			_ftp.Username = username;
			_ftp.Password = password;
			_ftp.Passive = passive;

			// proxy settings
			_ftp.FTPProxyAuthentication = requiresProxyAuth;

			if(requiresProxyAuth)
			{
			_ftp.FTPProxyType = (sfFTPLib.enumFTPProxyType)SmartFTP.enumFTPProxyType.ftpFTPProxyTypeSite;
			_ftp.FTPProxyPort = 21;
			_ftp.FTPProxyHost = proxyHost;
			}

			// set CLNT name
			_ftp.Client = "xxxxx";
			// log everything 
			_ftp.LogFile = "FTP_"+ DateTime.Now.ToShortDateString() +".log";


			_ftp.DataTransferMode = sfFTPLib.enumDataTransferMode.ftpDataTransferModeStream; 
			_ftp.DataTransferType = sfFTPLib.enumDataTransferType.ftpDataTransferTypeASCII;
			_ftp.DataProtection = sfFTPLib.enumDataProtection.ftpDataProtectionClear;

			_ftp.UseMessageLoop = true;
			
}


The Download method is exactly what you'll find in the SmartFTP Library C# sample, tweaked only slightly for some minor sytnax stuff. I have not included it here.

#2 deeshubby

deeshubby
  • Members
  • 3 posts

Posted 09 November 2006 - 06:48 PM

OK - I feel stupid...



This appears to be the offending line of code..
sfFTPLib.enumDataTransferType.ftpDataTransferTypeASCII


I changed it to ftpDataTransferTypeUnknown and it works fine now.
I could use the ftpDataTransferTypeImage, but because I'm hoping this library will do a dynamic determination, should I decide to open my application up to other file types.

Thanks-

Brian




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users