コード例 #1
0
ファイル: FTPClient.cs プロジェクト: StellarYan/MyFTP
        FTPReply?ReadNextReply()
        {
            if (CachedReply.Count > 0)
            {
                return(CachedReply.Dequeue());
            }
            string streamstring = null;

            try
            {
                streamstring = MyFTPHelper.ReadFromNetStream(controlStream);
            }
            catch (Exception exc)
            {
                throw exc;
            }
            string[] messages = streamstring.Split(new string[] { MyFTPHelper.FTPNewLine }, StringSplitOptions.RemoveEmptyEntries);
            Array.ForEach(messages, (m) => CachedReply.Enqueue(FTPReply.String2Reply(m)));
            if (CachedReply.Count > 0)
            {
                return(CachedReply.Dequeue());
            }
            else
            {
                return(null);
            }
        }
コード例 #2
0
ファイル: MyFTPHelper.cs プロジェクト: StellarYan/MyFTP
    public static FTPCommand?ReadNextCommand(NetworkStream stream)
    {
        if (CachedCommands.Count > 0)
        {
            return(CachedCommands.Dequeue());
        }
        string streamstring = null;

        try
        {
            streamstring = MyFTPHelper.ReadFromNetStream(stream);
        }
        catch (Exception exc)
        {
            throw exc;
        }
        string[] messages = streamstring.Split(new string[] { MyFTPHelper.FTPNewLine }, StringSplitOptions.RemoveEmptyEntries);
        Array.ForEach(messages, (m) => CachedCommands.Enqueue(FTPCommand.String2Command(m)));
        if (CachedCommands.Count > 0)
        {
            return(CachedCommands.Dequeue());
        }
        else
        {
            return(null);
        }
    }