Exemplo n.º 1
0
            private Task SaveAsync(string filePath, Core.Analysis.AnalysisSnapshot snapshot)
            {
                var directory = Path.GetDirectoryName(filePath);

                //
                _filesystem.CreateDirectory(directory);
                return(_filesystem.OpenWrite(filePath).ContinueWith(x => WriteAnalysisSnapshot(x, snapshot)));
            }
Exemplo n.º 2
0
        public Task OpenFileAsync(string filePath, long fileSize)
        {
            filePath = NormalizeAndEvaluate(filePath);

            Log.DebugFormat("Creating file '{0}'...", filePath);

            DeleteFile(filePath);

            var directoryPath = Path.GetDirectoryName(filePath);

            CreateDirectoryIfNecessary(directoryPath);

            var fileStream = _filesystem.OpenWrite(filePath);

            _files.Add(filePath, fileStream);

            Log.InfoFormat("Created file '{0}'", filePath);

            return(Task.FromResult(42));
        }
Exemplo n.º 3
0
        private static void SaveSnapshotAsync(IFilesystem filesystem, BitmapSource screenshot, string destination)
        {
            var encoder = new PngBitmapEncoder();

            using (var stream = new MemoryStream())
            {
                var frame = BitmapFrame.Create(screenshot);
                encoder.Frames.Add(frame);
                encoder.Save(stream);

                stream.Position = 0;

                var destinationDirectory = Path.GetDirectoryName(destination);
                filesystem.CreateDirectory(destinationDirectory);
                using (var fileStream = filesystem.OpenWrite(destination))
                {
                    stream.CopyTo(fileStream);
                }
            }
        }