/// <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 ); }
/// <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); }
/// <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); }
/// <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); }
/// <summary> /// Writes the specified byte array. /// </summary> /// <param name="bytes">The bytes to write. </param> public void WriteAllBytes(byte[] bytes) { QuickIOFile.WriteAllBytes(PathInfo, bytes); }
/// <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); }
/// <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)); }
/// <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)); }
/// <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)); }
/// <summary> /// Reads all lines. /// </summary> /// <returns>A string collection containing all lines.</returns> public IEnumerable <string> ReadAllLines() { return(QuickIOFile.ReadAllLines(PathInfo)); }
/// <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)); }
/// <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); }
/// <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); }
/// <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)); }
/// <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)); }
/// <summary> /// Writes the specified string. /// </summary> /// <param name="contents">The string to write to. </param> public void WriteAllText(string contents) { QuickIOFile.WriteAllText(PathInfo, contents); }
/// <summary> /// Reads all text. /// </summary> /// <returns>A string represents the content.</returns> public string ReadAllText() { return(QuickIOFile.ReadAllText(PathInfo)); }
/// <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)); }