Exemple #1
0
        public static ChunkFileInfo OpenWrite(string filePath)
        {
            Contract.Requires(!String.IsNullOrEmpty(filePath));
            Contract.Ensures(Contract.Result <ChunkFileInfo>() != null);
            Contract.Ensures(Contract.Result <ChunkFileInfo>().BaseStream != null);

            Check.IfArgumentNullOrEmpty(filePath, "filePath");

            ChunkFileInfo chunkFile = null;
            ChunkFileInfo cf        = null;

            try
            {
                cf            = new ChunkFileInfo(filePath);
                cf.BaseStream = File.OpenWrite(filePath);

                chunkFile = cf;
                cf        = null;
            }
            finally
            {
                if (cf != null)
                {
                    cf.Dispose();
                }
            }

            return(chunkFile);
        }
        public ChunkFileContextBuilder ForWriting(Stream stream)
        {
            if (_chunkFileInfo != null)
            {
                throw new InvalidOperationException("File already opened.");
            }

            _chunkFileInfo = ChunkFileInfo.CreateWrite(stream);
            return(this);
        }
        public ChunkFileContextBuilder ForWriting(string filePath)
        {
            if (_chunkFileInfo != null)
            {
                throw new InvalidOperationException("File already opened.");
            }

            _chunkFileInfo = ChunkFileInfo.OpenWrite(filePath);
            return(this);
        }