C# 클래스 CodeSnippets.IO.FileCloner

This class demonstrates multiple ways to clone files stored in the file system. In all cases, the source file is stored in the file system. Where the return type is a MemoryStream, the destination file will be stored only on that MemoryStream. Where the return type is a FileStream, the destination file will be stored in the file system and opened on that FileStream.
The contents of the MemoryStream instances returned by the sample methods can be written to a file as follows: var stream = ReadAllBytesToMemoryStream(sourcePath); File.WriteAllBytes(destPath, stream.GetBuffer()); You can use MemoryStream.GetBuffer in cases where the MemoryStream was created using MemoryStream() or MemoryStream(int). In other cases, you can use the MemoryStream.ToArray method, which copies the internal buffer to a new byte array. Thus, GetBuffer() should be a tad faster.
파일 보기 프로젝트 열기: shendongnian/code

공개 메소드들

메소드 설명
CopyFileAndOpenFileStream ( string sourcePath, string destPath ) : FileStream
CopyFileStreamToFileStream ( string sourcePath, string destPath ) : FileStream
CopyFileStreamToMemoryStream ( string path ) : MemoryStream
ReadAllBytesToMemoryStream ( string path ) : MemoryStream

메소드 상세

CopyFileAndOpenFileStream() 공개 정적인 메소드

public static CopyFileAndOpenFileStream ( string sourcePath, string destPath ) : FileStream
sourcePath string
destPath string
리턴 FileStream

CopyFileStreamToFileStream() 공개 정적인 메소드

public static CopyFileStreamToFileStream ( string sourcePath, string destPath ) : FileStream
sourcePath string
destPath string
리턴 FileStream

CopyFileStreamToMemoryStream() 공개 정적인 메소드

public static CopyFileStreamToMemoryStream ( string path ) : MemoryStream
path string
리턴 MemoryStream

ReadAllBytesToMemoryStream() 공개 정적인 메소드

public static ReadAllBytesToMemoryStream ( string path ) : MemoryStream
path string
리턴 MemoryStream