private void RemoveFile(dodSON.Core.FileStorage.IFileStoreItem item)
        {
            var filename = System.IO.Path.Combine(RootPath, CleanFilenameString(item.RootFilename));

            if (System.IO.File.Exists(filename))
            {
                System.IO.File.Delete(filename);
            }
        }
Exemple #2
0
        private void ZipperRemoveFile(System.IO.Compression.ZipArchive zipper, dodSON.Core.FileStorage.IFileStoreItem item)
        {
            // find existing zip item
            var entry = zipper.Entries.FirstOrDefault((e) => { return(e.FullName.Equals(item.RootFilename, StringComparison.InvariantCultureIgnoreCase)); });

            if (entry != null)
            {
                entry.Delete();
            }
        }
        private void AddFile(dodSON.Core.FileStorage.IFileStoreItem item)
        {
            var destFilename = System.IO.Path.Combine(RootPath, CleanFilenameString(item.RootFilename));

            if (!string.Equals(item.OriginalFilename, destFilename, StringComparison.InvariantCultureIgnoreCase))
            {
                CreateDirectory(System.IO.Path.GetDirectoryName(destFilename));
                System.IO.File.Copy(item.OriginalFilename, destFilename, true);
            }
        }
Exemple #4
0
        /// <summary>
        /// Will extract the <paramref name="item"/> from the .zip file to the destination root path given in the method <see cref="Extract_StartUp(string, out object)"/>.
        /// </summary>
        /// <param name="item">The store item to extract.</param>
        /// <param name="state">A reference to an initialized System.IO.Compression.ZipArchive object. This reference, created in the <see cref="Extract_StartUp(string, out object)"/> will be passed to all Extract_ methods.</param>
        /// <returns>The filename of the extracted file.</returns>
        protected override string Extract_ExtractFile(dodSON.Core.FileStorage.IFileStoreItem item, object state)
        {
            // find zip entry
            var found = ((System.IO.Compression.ZipArchive)state).Entries.FirstOrDefault((zf) => { return(CleanFilenameString(zf.FullName).Equals(item.RootFilename, StringComparison.InvariantCultureIgnoreCase)); });

            // extract file
            if (found != null)
            {
                return(ZipperExtractFile(_Extract_DestRootPath, found));
            }
            return("");
        }