示例#1
0
        public long GetFileSize(String file)
        {
            IntPtr remoteFile = new IntPtr(WinINet.FtpOpenFile(m_hConnect, file, WinApi.GENERIC_READ, WinINet.FTP_TRANSFER_TYPE_BINARY, IntPtr.Zero));

            if (remoteFile == IntPtr.Zero)
            {
            }
            else
            {
                try
                {
                    Int32 sizeHigh = 0;
                    Int32 sizeLo   = WinINet.FtpGetFileSize(remoteFile, ref sizeHigh);

                    long fileSize = ((long)sizeHigh << 32) | sizeLo;
                    return(fileSize);
                }
                catch (Exception ex)
                {
                }
                finally
                {
                    WinINet.InternetCloseHandle(remoteFile);
                }
            }
            return(0);
        }