I didn't like to play with a blog. I also registered this blog in the blog Park this time.
But there is no content, so I want to add anything.
Most of the gadgets recently developed by Microsoft are related to file operations/I/O. Therefore, I am going to sort out these two days and paste some things that may be shared with you, I hope it will be helpful for beginners of C!
(For more sample Code, visit the microsoft learner help website Code smaples from microsoft: http://1code.codeplex.com, download microsoft's All-in-onecode framework, this is a tool that I recently developed in Microsoft to help developers learn. It can be found that there are many sample codes for the learner's reference .)
C # You can call a third-party dll to package a zip file to get twice the result with half the effort, and the dll is free of charge: SharpZipLib
After downloading and decompressing the file, run the ICSharpCode command. sharpZipLib. copy the dll to the directory of the current project (if you are lazy, you can directly copy it to the binDebug directory of the current project), right-click the project reference opened by VS, and add the reference ICSharpCode. sharpZipLib. dll
Then, right-click the project opened by VS to create a class named ZipHelper. cs, clear all codes in the class, copy the following code, and paste it:
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;
using
System.IO;
using
System.Diagnostics;
using
ICSharpCode.SharpZipLib;
using
ICSharpCode.SharpZipLib.Zip;
using
ICSharpCode.SharpZipLib.Checksums;
using
ICSharpCode.SharpZipLib.Core;
namespace
ZipOneCode.ZipProvider
{
public
class
ZipHelper
{
/// <summary>
/// Compressed file
/// </summary>
/// <param name="sourceFilePath"></param>
/// <param name="destinationZipFilePath"></param>
public
static
void
CreateZip(
string
sourceFilePath,
string
destinationZipFilePath)
{
if
(sourceFilePath[sourceFilePath.Length - 1] != System.IO.Path.DirectorySeparatorChar)
sourceFilePath += System.IO.Path.DirectorySeparatorChar;
ZipOutputStream zipStream =
new
ZipOutputStream(File.Cr