Exemplo n.º 1
0
        // Copies a file from the stream into the specified temp file.
        private static async Task CopyFileFromStream(ITimelineService api, Stream stream, string tempFile)
        {
            Stream tempStream = null;

            try
            {
                tempStream = api.FileOpenWrite(tempFile);
                await stream.CopyToAsync(tempStream);
            }
            finally
            {
                // We do it like this to prevent "object disposed" errors in tests.
                if (tempStream != null)
                {
                    api.DisposeStream(tempStream);
                }
            }
        }