http://bbs.csdn.net/topics/390460167
看到这么好的帖子,竟然是 WinCE 下 FTP 的实现,但却发在 .NET技术 > C# 区,相信部分 CE 的爱好者不一定能看到,所以转到 CE 的坛子。
多谢 zhouzhangkui 开源出来!
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;<br>
namespace SimpleFtp
{
internal class WinAPI
{
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public class WIN32_FIND_DATA
{
public UInt32 dwFileAttributes = 0;
public FILETIME ftCreationTime;
public FILETIME ftLastAccessTime;
public FILETIME ftLastWriteTime;
public UInt32 nFileSizeHigh = 0;
public UInt32 nFileSizeLow = 0;
public UInt32 dwReserved0 = 0;
public UInt32 dwReserved1 = 0;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
public string cFileName = null;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 14)]
public string cAlternateFileName = null;
};
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public class FILETIME
{
public int dwLowDateTime = 0;
public int dwHighDateTime = 0;
};<br>
public const int INTERNET_FLAG_PASSIVE = 0x8000000; //被动模式
public const int INTERNET_FLAG_PORT = 0x0; //主动模式<br>
public const uint INTERNET_FLAG_RELOAD = 0x80000000; //
public const uint INTERNET_FLAG_KEEP_CONNECTION = 0x400000; //
public const uint INTERNET_FLAG_MULTIPART = 0x200000; //<br>
public const int INTERNET_OPEN_TYPE_PRECONFIG = 0;
public const int INTERNET_OPEN_TYPE_DIRECT = 1;
public const int INTERNET_OPEN_TYPE_PROXY = 3;<br>
public const int INTERNET_SERVICE_FTP = 1;
public const int INTERNET_SERVICE_GOPHER = 2;
public const int INTERNET_SERVICE_HTTP = 3;<br>
public const uint FTP_TRANSFER_TYPE_ASCII = 0x1;
public const uint FTP_TRANSFER_TYPE_BINARY = 0x2;<br>
public const int FILE_ATTRIBUTE_READONLY = 0x1;
public const int FILE_ATTRIBUTE_HIDDEN = 0x2;
public const int FILE_ATTRIBUTE_SYSTEM = 0x4;
public const int FILE_ATTRIBUTE_DIRECTORY = 0x10;
public const int FILE_ATTRIBUTE_ARCHIVE = 0x20;
public const int FILE_ATTRIBUTE_NORMAL = 0x80;
public const int FILE_ATTRIBUTE_TEMPORARY = 0x100;
public const int FILE_ATTRIBUTE_COMPRESSED = 0x800;
// 连接和初始化
[DllImport("kernel32.dll", CharSet = CharSet.Auto)]