[DllImport("wininet.dll", CharSet = CharSet.Auto)]
public static extern bool InternetGetConnectedState(ref uint ulFlags, uint
ulReserved);
[DllImport("wininet.dll", CharSet = CharSet.Auto)]
public static extern bool FtpSetCurrentDirectory(IntPtr ulSession, string
strPath);
[DllImport("wininet.dll", CharSet = CharSet.Auto)]
public static extern IntPtr FtpFindFirstFile(IntPtr ulSession, string strPath
, [In, Out] WIN32_FIND_DATA dirData, ulong ulFlags, ulong ulContext);
[DllImport("wininet.dll", CharSet = CharSet.Auto)]
public static extern bool FtpGetFile(IntPtr ulSession, string strRemoteFile,
string strLocalFile, bool bolFailIfExist, ulong ulFlags, ulong ulInetFals, ulong
ulContext);
[DllImport("wininet.dll", CharSet = CharSet.Auto)]
public static extern bool FtpPutFile(IntPtr ulSession, string strLocalFile,
string strRemoteFile, ulong ulFlags, ulong ulContext);
[DllImport("wininet.dll", CharSet = CharSet.Auto)]
public static extern bool FtpDeleteFile(IntPtr ulSession, string strFileName);
[DllImport("wininet.dll", CharSet = CharSet.Auto)]
public static extern bool InternetCloseHandle(IntPtr ulSession);
在WININET.DLL中还有很多其他功能的函数,详细内容请看:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wininet/wininet/wininet_reference.asp
翻译了上面的函数,其实已经成功了80%,后面的工作是SO EASY,就是简单地调用,例子我后面抽时间补上,这种方式的好处是只要SERVER端开放了21端口,它就可以穿越防火墙,还是很令人激动的;不过缺点也是有的,无法实现断点续传。从MSDN的介绍上来看,WINDOWS中实现FTP的方式实际上是利用了HTTP协议,而非真正地遵循FTP协议来实现的。