private bool _uploadData(byte[] buffer) { long writtenBytes = 0; for (int i = 0; i < buffer.Length; i += 1024) { writtenBytes = i + 1023; if (writtenBytes > buffer.Length) { writtenBytes = buffer.Length - 1; } for (int j = i; j <= writtenBytes; j++) { PassiveClientWriter.Write(buffer[j]); } PassiveClientWriter.Flush(); } PassiveClient.Close(); PassiveClient = null; string answer = ReadAnswer(); EnterASCIIMode(); return(answer.Trim().StartsWith("226")); }
public void Disconnect() { if (ActiveClient != null && ActiveClient.Connected) { ActiveClient.Close(); ActiveClient = null; } if (PassiveClient != null && PassiveClient.Connected) { PassiveClient.Close(); PassiveClient = null; } }
public List <IOElement> ListFiles() { _checkConnected(); string answer = SendCommandReadAnswer("LIST"); string passiveAnswer = ReadAnswer(PassiveClient, "000", false).Trim(); //dispose passive objects PassiveClient.Close(); PassiveClient = null; PassiveClientReader.Close(); PassiveClientReader = null; if (answer.Contains("226") == false) { answer = ReadAnswer(); } List <IOElement> Files = new List <IOElement>(); if (passiveAnswer.Length == 0) { return(Files); } //detect os for file listing parsing int os = 0; string[] osHelper = passiveAnswer.Split('\n'); if (osHelper.Length > 0) { os = (osHelper[0][10] == ' ' && osHelper[0][9] != ' ') ? 0 : 1; } Files = ((OS & (OSType)os) == OSType.Windows) ? IOElement.ParseWindowsFiles(passiveAnswer) : IOElement.ParseLinuxFiles(passiveAnswer); Files.Sort(); return(Files); }