CSharpRTMP.Common.MediaFile.CacheMediaFile C# (CSharp) Method

CacheMediaFile() public static method

public static CacheMediaFile ( string path, FileAccess fileAccess = FileAccess.Read ) : MediaFile
path string
fileAccess FileAccess
return MediaFile
        public static MediaFile CacheMediaFile(string path, FileAccess fileAccess = FileAccess.Read)
        {
            try
            {
                var fileStream = new FileStream(path, FileMode.Open, fileAccess);
                var dataStream = new MemoryStream();
                fileStream.CopyTo(dataStream);
                dataStream.Position = 0;
                fileStream.Dispose();
                return new MediaFile(path) { DataStream = dataStream, Br = fileAccess != FileAccess.Write ? new N2HBinaryReader(dataStream) : null, Bw = fileAccess != FileAccess.Read ? new H2NBinaryWriter(dataStream) : null };
            }
            catch (Exception ex)
            {
                Logger.FATAL("{0}", ex);
                return null;
            }
        }