示例#1
0
    public long Write(Stream sInput, string pathDestFile)
    {
        threadDone.Reset();

        long res = 0;

        using (FileStream fs = new FileStream(pathDestFile, FileMode.CreateNew, FileAccess.Write))
        {
            res = fs.Length;

            bReading     = false;
            m_fileStream = fs;
            threadWakeUp.Set();

            while (true)
            {
                int read = sInput.Read(pc.prodGetBuffer(), 0, pc.bufferLength);
                pc.prodSubmitChunk(read);
                if (read <= 0)
                {
                    break;
                }
            }

            threadDone.WaitOne();
            fs.Flush();

            m_fileStream = null;
        }
        return(res);
    }