public static void CopyFile(string sourcePath, RenderOutputMethod renderOutput, string relativeDestPath, string mimeType) { FileIdentification fileIdentificationStatic = FileOutputMethod.GetFileIdentificationStatic(sourcePath); FileIdentification fileIdentification = renderOutput.GetFileIdentification(relativeDestPath); if (fileIdentificationStatic.CompareTo(fileIdentification) == 0) { return; } Stream stream = new FileStream(sourcePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); Stream stream2 = renderOutput.CreateFile(relativeDestPath, mimeType); byte[] buffer = new byte[65536]; while (true) { int num = stream.Read(buffer, 0, 65536); if (num == 0) { break; } stream2.Write(buffer, 0, num); } stream.Close(); stream2.Close(); }