예제 #1
0
        /// <summary>
        /// Compresses a directory by using <see>
        ///         <cref>ZipFile.CreateFromDirectory</cref>
        ///     </see>
        /// </summary>
        /// <param name="directoryFullPath">Directory fullname to zip</param>
        /// <param name="zipFullPath">Zipfile fullname to save</param>
        /// <param name="overWriteExistingZip">true to overwrite existing zipfile</param>
        /// <param name="compressionLevel"><see cref="CompressionLevel"/></param>
        /// <param name="includeBaseDirectory">True to include basedirectory</param>
        /// <exception cref="DirectoryNotFoundException">if <paramref name="directoryFullPath"/> does not exist.</exception>
        /// <exception cref="FileAlreadyExistsException">if <paramref name="zipFullPath"/> does exist and <paramref name="overWriteExistingZip"/> is <i>false</i>.</exception>
        public static void Compress(String directoryFullPath, String zipFullPath, bool overWriteExistingZip = false, CompressionLevel compressionLevel = CompressionLevel.Fastest, bool includeBaseDirectory = false)
        {
            Contract.Requires(!String.IsNullOrWhiteSpace(directoryFullPath));
            Contract.Requires(!String.IsNullOrWhiteSpace(zipFullPath));

            if (!QuickIODirectory.Exists(directoryFullPath))
            {
                throw new DirectoryNotFoundException($"Directory to zip '{directoryFullPath}' does not exist.");
            }

            if (!overWriteExistingZip && (QuickIOFile.Exists(zipFullPath)))
            {
                throw new FileAlreadyExistsException($"The target zipFile name '{zipFullPath}' already exists.");
            }

            throw new NotImplementedException();
            //ZipFile.CreateFromDirectory( directoryFullPath, zipFullPath, compressionLevel, includeBaseDirectory );
        }
예제 #2
0
 /// <summary>
 /// Writes the specified string.
 /// </summary>
 /// <param name="contents">The string to write to. </param>
 /// <param name="encoding">The encoding to apply to the string.</param>
 public void WriteAllText(string contents, Encoding encoding)
 {
     QuickIOFile.WriteAllText(PathInfo, contents, encoding);
 }
예제 #3
0
 /// <summary>
 /// Writes a collection of strings.
 /// </summary>
 /// <param name="contents">The lines write to.</param>
 /// <param name="encoding">The character encoding to use.</param>
 public void WriteAllLines(IEnumerable <string> contents, Encoding encoding)
 {
     QuickIOFile.WriteAllLines(PathInfo, contents, encoding);
 }
예제 #4
0
 /// <summary>
 /// Writes a collection of strings.
 /// Uses UTF-8 without Emitted UTF-8 identifier.
 /// </summary>
 /// <param name="contents">The lines write to.</param>
 public void WriteAllLines(IEnumerable <string> contents)
 {
     QuickIOFile.WriteAllLines(PathInfo, contents);
 }
예제 #5
0
 /// <summary>
 /// Writes the specified byte array.
 /// </summary>
 /// <param name="bytes">The bytes to write. </param>
 public void WriteAllBytes(byte[] bytes)
 {
     QuickIOFile.WriteAllBytes(PathInfo, bytes);
 }
예제 #6
0
 /// <summary>
 /// Writes the specified byte array.
 /// </summary>
 /// <param name="bytes">The bytes to write. </param>
 public void WriteAllBytes(IEnumerable <byte> bytes)
 {
     QuickIOFile.WriteAllBytes(PathInfo, bytes);
 }
예제 #7
0
 /// <summary>
 /// Reads all text with the specified encoding.
 /// </summary>
 /// <param name="encoding">The encoding applied to the content. </param>
 /// <returns>A string represents the content.</returns>
 public string ReadAllText(Encoding encoding)
 {
     return(QuickIOFile.ReadAllText(PathInfo, encoding));
 }
예제 #8
0
 /// <summary>
 /// Opens an existing UTF-8 encoded text file for reading.
 /// </summary>
 /// <returns>A <see cref="StreamReader"/>.</returns>
 public StreamReader OpenText()
 {
     return(QuickIOFile.OpenText(FullNameUnc));
 }
예제 #9
0
 /// <summary>
 /// Reads all lines with the specified encoding
 /// </summary>
 /// <param name="encoding">The encoding applied to the contents. </param>
 /// <returns>A string collection containing all lines.</returns>
 public IEnumerable <string> ReadAllLines(Encoding encoding)
 {
     return(QuickIOFile.ReadAllLines(PathInfo, encoding));
 }
예제 #10
0
 /// <summary>
 /// Reads all lines.
 /// </summary>
 /// <returns>A string collection containing all lines.</returns>
 public IEnumerable <string> ReadAllLines()
 {
     return(QuickIOFile.ReadAllLines(PathInfo));
 }
예제 #11
0
 /// <summary>
 /// Reads the contents of the file into a byte collection.
 /// </summary>
 /// <returns>A byte collection containing the contents.</returns>
 public byte[] ReadAllBytes(Int32 readBuffer = QuickIORecommendedValues.DefaultReadBufferBytes)
 {
     return(QuickIOFile.ReadAllBytes(PathInfo, readBuffer));
 }
예제 #12
0
 /// <summary>
 /// Appends the specified string.
 /// If the file does not exist, it creates the file.
 /// </summary>
 /// <param name="contents">The string to append to the file.</param>
 /// <param name="encoding">The character encoding.</param>
 /// <remarks>http://msdn.microsoft.com/en-us/library/ms143356(v=vs.110).aspx</remarks>
 public void AppendAllText(string contents, Encoding encoding)
 {
     QuickIOFile.AppendAllText(PathInfo, contents, encoding);
 }
예제 #13
0
 /// <summary>
 /// Appends lines to a file.
 /// Uses UTF-8 Encoding.
 /// </summary>
 /// <param name="contents">The lines to append.</param>
 public void AppendAllLines(IEnumerable <string> contents)
 {
     QuickIOFile.AppendAllLines(PathInfo, contents, Encoding.UTF8);
 }
예제 #14
0
 /// <summary>
 /// Opens an existing file or creates a new file for appending.
 /// </summary>
 /// <returns>An unshared <see cref="FileStream"/> with Write access.</returns>
 public FileStream OpenAppend()
 {
     return(QuickIOFile.OpenAppend(FullNameUnc));
 }
예제 #15
0
 /// <summary>
 /// Opens an existing file or creates a new file for writing.
 /// </summary>
 /// <returns>An unshared <see cref="FileStream"/> with Write access.</returns>
 public FileStream OpenWrite()
 {
     return(QuickIOFile.OpenWrite(FullNameUnc));
 }
예제 #16
0
 /// <summary>
 /// Writes the specified string.
 /// </summary>
 /// <param name="contents">The string to write to. </param>
 public void WriteAllText(string contents)
 {
     QuickIOFile.WriteAllText(PathInfo, contents);
 }
예제 #17
0
 /// <summary>
 /// Reads all text.
 /// </summary>
 /// <returns>A string represents the content.</returns>
 public string ReadAllText()
 {
     return(QuickIOFile.ReadAllText(PathInfo));
 }
예제 #18
0
 /// <summary>
 /// Opens a <see cref="FileStream"/>
 /// </summary>
 /// <param name="mode"><see cref="FileMode"/> </param>
 /// <param name="access"><see cref="FileAccess"/></param>
 /// <param name="share"><see cref="FileShare"/></param>
 /// <returns><see cref="FileStream"/></returns>
 /// <remarks>http://msdn.microsoft.com/en-us/library/y973b725(v=vs.110).aspx</remarks>
 public FileStream Open(FileMode mode, FileAccess access = FileAccess.Read, FileShare share = FileShare.None)
 {
     return(QuickIOFile.Open(FullNameUnc, mode, access, share));
 }