/// <summary> /// Receive a binary file from the cvs server. /// </summary> /// <param name="inputStream"></param> /// <param name="fileName"></param> /// <param name="length"></param> public virtual void ReceiveBinaryFile(CvsStream inputStream, String fileName, int length) { byte[] buffer = new byte[length]; inputStream.ReadBlock(buffer, length); FileStream fs = System.IO.File.Create(fileName); fs.Write(buffer, 0, length); fs.Close(); }
/// <summary> /// Receive a text file from the cvs server. /// </summary> /// <param name="inputStream">Input stream from the cvs server.</param> /// <param name="fileName">The name of the file to be created.</param> /// <param name="length">The number of bytes the file contains.</param> public virtual void ReceiveTextFile(CvsStream inputStream, string fileName, int length) { byte[] buffer = new byte[length]; inputStream.ReadBlock(buffer, length); // Take care to preserve none printable or other culture token // encodings using (MemoryStream ms = new MemoryStream(buffer, 0, length)) { StreamReader sr = new StreamReader(ms, Encoding.Default); StreamWriter sw = new StreamWriter(fileName, false, Encoding.Default); while (sr.Peek() >= 0) { sw.WriteLine(sr.ReadLine()); } sw.Close(); sr.Close(); } }