(000221) 11.01.2010 10:25:00 - (not logged in) (192.168.0.231)> Connected, sending welcome message...
(000221) 11.01.2010 10:25:02 - (not logged in) (192.168.0.231)> USER 0050
(000221) 11.01.2010 10:25:02 - (not logged in) (192.168.0.231)> 331 Password required for 0050
(000221) 11.01.2010 10:25:02 - (not logged in) (192.168.0.231)> PASS *****
(000221) 11.01.2010 10:25:02 - 0050 (192.168.0.231)> 230 Logged on
(000221) 11.01.2010 10:25:03 - 0050 (192.168.0.231)> CWD 1/
(000221) 11.01.2010 10:25:03 - 0050 (192.168.0.231)> 250 CWD successful. "/1" is current directory.
(000221) 11.01.2010 10:25:05 - 0050 (192.168.0.231)> TYPE I
(000221) 11.01.2010 10:25:05 - 0050 (192.168.0.231)> 200 Type set to I
(000221) 11.01.2010 10:25:06 - 0050 (192.168.0.231)> PASV
(000221) 11.01.2010 10:25:06 - 0050 (192.168.0.231)> 227 Entering Passive Mode (192,168,1,177,197,15)
(000222) 11.01.2010 10:25:15 - (not logged in) (192.168.0.231)> Connected, sending welcome message...
(000222) 11.01.2010 10:25:16 - (not logged in) (192.168.0.231)> USER 0050
(000222) 11.01.2010 10:25:16 - (not logged in) (192.168.0.231)> 331 Password required for 0050
(000222) 11.01.2010 10:25:16 - (not logged in) (192.168.0.231)> PASS *****
(000222) 11.01.2010 10:25:16 - 0050 (192.168.0.231)> 230 Logged on
(000222) 11.01.2010 10:25:17 - 0050 (192.168.0.231)> CWD p/
(000222) 11.01.2010 10:25:17 - 0050 (192.168.0.231)> 250 CWD successful. "/p" is current directory.
(000222) 11.01.2010 10:25:19 - 0050 (192.168.0.231)> TYPE I
(000222) 11.01.2010 10:25:19 - 0050 (192.168.0.231)> 200 Type set to I
(000222) 11.01.2010 10:25:20 - 0050 (192.168.0.231)> PASV
(000222) 11.01.2010 10:25:20 - 0050 (192.168.0.231)> 227 Entering Passive Mode (192,168,1,177,197,16)
уже мыслей нет. Entering Passive Mode и все! висим.
class FTP
{
public static bool CloseHandleFTP(int ftpHaqndle)
{
if (!Program.InternetCloseHandle(ftpHaqndle))
{
return false;
}
return true;
}
public static int OpenFTP(string FTPAddr, int FTPPort, string FTPLog, string FTPPWD)
{
int InetHaqndle = Program.InternetOpen("Order", 1, 0, 0, 0x8000000);
if (InetHaqndle == 0)
{
return 0;
}
int ftpHaqndle = Program.InternetConnect(InetHaqndle, FTPAddr, FTPPort, FTPLog, FTPPWD, 1, 0x8000000, 0);
if (ftpHaqndle == 0)
{
return 0;
}
return ftpHaqndle;
}
public static bool ChDirFTP(int ftpHaqndle, string name)
{
if (!Program.FtpSetCurrentDirectory(ftpHaqndle, name))
{
return false;
}
return true;
}
public static bool GetFileFTP(int ftpHaqndle, string name, string newpath)
{
//string newpath = Program.StartupPath() + name;
// string newpath = "/pbase/" + name;
if (!Program.FtpGetFile(ftpHaqndle, name, newpath, false, 0x00000080, 0x8000000, 0))
{
return false;
}
return true;
}
public static bool FtpUploadFile(int ftpHaqndle, string localName, string remouteName)
{
// string newpath = Program.StartupPath() + localName;
if (!Program.FtpPutFile(ftpHaqndle, localName, remouteName, 0x8000000, 0))
{
return false;
}
return true;
}
public static bool FtpDeleteFile(int ftpHaqndle, string pathDeleteFile)
{
//string newpath = Program.StartupPath() + name;
// string newpath = "/pbase/" + name;
if (!Program.FtpDeleteFile(ftpHaqndle, pathDeleteFile))
{
return false;
}
return true;
}
}
hndl = FTP.OpenFTP(Settings_Ip_InFTP, int.Parse(Settings_Port_InFTP), Settings_номер_Агента, Settings_Пароль_In);
if (hndl == 0)
{
Logging("Ощибка подключение " + Settings_Ip_FTP);
return;
}
else { Logging("Соединение " + Settings_Ip_FTP + " установлено"); }
if (!FTP.ChDirFTP(hndl, "p/"))
{
Logging("Ощибка директория не найдена");
FTP.CloseHandleFTP(hndl);
return;
}
else { Logging("директория найдена"); }
if (!FTP.GetFileFTP(hndl, "price.txt", PathFile + "price.txt"))
{
Logging("файл Price.txt не получен");
FTP.CloseHandleFTP(hndl);
return;
}
else { Logging("файл Price.txt получен"); }
FTP.CloseHandleFTP(hndl);
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[MTAThread]
static void Main()
{
Application.Run(new Form1());
}
[DllImport("wininet.dll", CharSet = CharSet.Auto)]
public static extern int InternetOpen(
string lpszAgent,
int dwAccessType,
int lpszProxy,
int lpszProxyBypass,
int dwFlags
);
[DllImport("wininet.dll", CharSet = CharSet.Auto)]
public static extern int InternetConnect(
int hInternet,
string lpszServerName,
int nServerPort,
string lpszUserName,
string lpszPassword,
int dwService,
int dwFlags,
int dwContext
);
[DllImport("wininet.dll", CharSet = CharSet.Auto)]
public static extern bool FtpSetCurrentDirectory(
int hConnect,
string lpszDirectory
);
[DllImport("wininet.dll", CharSet = CharSet.Auto)]
public static extern bool FtpGetFile(
int hConnect,
string lpszRemoteFile,
string lpszNewFile,
bool fFailIfExists,
int dwFlagsAndAttributes,
int dwFlags,
int dwContext
);
[DllImport("wininet.dll", CharSet = CharSet.Auto)]
public static extern bool FtpPutFile(
int hConnect,
string lpszLocalFile,
string lpszNewRemoteFile,
int dwFlags,
int dwContext
);
[DllImport("wininet.dll", CharSet = CharSet.Auto)]
public static extern bool FtpDeleteFile(
int hConnect,
string lpszFileName
);
[DllImport("wininet.dll", CharSet = CharSet.Auto)]
public static extern bool InternetCloseHandle(
int hInternet
);
public static string StartupPath()
{
string path = Assembly.GetExecutingAssembly().ManifestModule.FullyQualifiedName;
path = Path.GetDirectoryName(path) + "\\";
return path;
}
}