/// <summary> ///**************************************************/ /// Tao ket noi den FTP /// Tham so: /// lpszServerNam: IP hoac ten may muon ket noi toi /// lpszUsername: Username dung de ket noi /// lpszPassword: Password dung de ket noi /// Tra ve: /// true: thanh cong /// false: that bai ///**************************************************/ /// </summary> public bool Connect(string lpszServerName, string lpszUsername, string lpszPassword) { if (m_HConnect.ToPointer() != null) { // Xu ly neu da co ket noi den FTP roi CWinINet.InternetCloseHandle(m_HConnect); } m_HConnect = CWinINet.InternetConnect(FTPClient.Program.m_HOpen, lpszServerName, CWinINet.INTERNET_DEFAULT_FTP_PORT, lpszUsername, lpszPassword, CWinINet.INTERNET_SERVICE_FTP, 0x08000000, 0); // bool k = CWinINet.FtpSetCurrentDirectory(m_HConnect, "12"); // uint err = new uint(); // StringBuilder subBlock = new StringBuilder(256); // uint len = 260; // bool kq2 = CWinINet.InternetGetLastResponseInfo(ref err, subBlock, ref len); // bool kq2 = CWinINet.FtpGetCurrentDirectory(m_HConnect, subBlock, ref len); // bool kq2 = CWinINet.FtpDeleteFile(m_HConnect, "12.txt"); // CAPIFunctions.SetCurrentDirectory("C:\\"); // bool kq2 = CWinINet.FtpRemoveDirectory(m_HConnect, "2/3"); // bool kq2 = CWinINet.FtpPutFile(m_HConnect, "Chuyen Tinh Ao Ca - Quang Linh.mp3", // "Chuyen Tinh Ao Ca - Quang Linh.mp3", CWinINet.FTP_TRANSFER_TYPE_BINARY, 0); // bool kq2 = CWinINet.FtpGetFile(m_HConnect, "kv.txt", "kv.txt", false, 0x00000080, CWinINet.FTP_TRANSFER_TYPE_BINARY, 0); // uint err = CAPIFunctions.GetLastError(); // IntPtr h = CWinINet.FtpOpenFile(m_HConnect, "kv.txt", // CWinINet.GENERIC_READ, CWinINet.FTP_TRANSFER_TYPE_BINARY, 0); // uint len2 = new uint(); // uint len1 = CWinINet.FtpGetFileSize(h, ref len2); // CWinINet.InternetCloseHandle(h); // CWinINet.FtpRenameFile(m_HConnect, "kv.txt", "kv2.txt"); // WIN32_FIND_DATA t = new WIN32_FIND_DATA(); // IntPtr kq = CWinINet.FtpFindFirstFile(m_HConnect, null, t, 0x80000000, 0); // bool kq1 = CWinINet.InternetFindNextFile(kq, t); // kq1 = CWinINet.InternetFindNextFile(kq, t); // kq1 = CWinINet.InternetFindNextFile(kq, t); return(m_HConnect.ToPointer() != null); }