Using WinRAR in C # to implement encrypted compression and decompression files

Source: Internet
Author: User
Tags comments rar zip

The main implementation of this example is:

1. Compressed folder and its following files

2. Compressed folder files

3. Compressed folder and its next file for RAR or zip

4. Decompression

5. Encryption compression and decryption compression

-----------

The sample code is as follows:

?

protected void Button1_Click (object sender, EventArgs e)

{

String Strtxtpath = "C://freezip//free.txt";

String Strzippath = "C://freezip//free.zip";

System.Diagnostics.Process Process1 = new System.Diagnostics.Process ();

Process1.StartInfo.FileName = "Winrar.exe";

Process1.StartInfo.CreateNoWindow = true;

1

Compress C:/freezip/free.txt (that is, folders and their files freezip/free.txt)

To C:/freezip/free.rar

Strzippath = "C://freezip//free";//The default compression mode is. rar

Process1.StartInfo.Arguments = "A-r" + Strzippath + "" + Strtxtpath;

2

Compress C:/freezip/free.txt (that is, folders and their files freezip/free.txt)

To C:/freezip/free.rar

Strzippath = "C://freezip//free";//Set compression mode to. zip

Process1.StartInfo.Arguments = "A-afzip" + Strzippath + "" + Strtxtpath;

3

Compress C:/freezip/free.txt (that is, folders and their files freezip/free.txt)

To C:/freezip/free.zip directly set to Free.zip

Process1.StartInfo.Arguments = "A-r" +strzippath+ "" + Strtxtpath;

4

Move compressed C:/freezip/free.txt (that is, folders and their files freezip/free.txt)

The original file will not exist after C:/freezip/free.rar compression

Process1.StartInfo.Arguments = "M" + Strzippath + "" + Strtxtpath;

5

Compressed c:/freezip/under free.txt (ie file free.txt)

To C:/freezip/free.zip directly set to Free.zip only files without folders

Process1.StartInfo.Arguments = "A-ep" + Strzippath + "" + Strtxtpath;

6

Decompression C:/freezip/free.rar

To c:/freezip/

Strtxtpath = "c://freezip//";

Process1.StartInfo.Arguments = "X" + Strzippath + "" + Strtxtpath;

7

Encrypting compressed c:/freezip/free.txt (that is, folders and their files freezip/free.txt)

To c:/freezip/free.zip password 123456 Note No spaces between parameters

Process1.StartInfo.Arguments = "a-p123456" + Strzippath + "" + Strtxtpath;

8

C:/freezip/free.rar of uncompressed encryption

To c:/freezip/password 123456 Note No spaces between parameters

Strtxtpath = "c://freezip//";

Process1.StartInfo.Arguments = "x-p123456" + Strzippath + "" + Strtxtpath;

Process1.start ();

if (process1.hasexited)

{

Response.Write ("complete");

}

}

# re:c# (encrypted) compressed and uncompressed related folders and files

More WinRAR commands (from the WinRAR help document)

A add files to a compressed file

C Add compressed file comments

d Delete files from compressed files

E extract compression from compressed file, ignore path

f refreshing files in a compressed file

I find a string in a compressed file

K Lock Compressed file

m moving files and folders to compressed files

R repair of damaged compressed files

RC Rebuilding of Lost volumes

RN Renaming compressed Files

RR[N] Add Data Recovery records

Rv[n] Create a recovery volume

S[name] Convert a compressed file into a self-extracting file type

S-delete self-extracting module

T Test compressed file

U update files from compressed files

X extract compression from compressed file with full path name reply more comments

# re:c# (encrypted) compressed and uncompressed related folders and files

More WinRAR letters (quotes from the WinRAR help document)

-AC clears the archive attribute after compression or decompression

-AD Append compressed file name to target path

-af< type > Specify compressed file format

-ag[format] to generate a compressed file name with the current date

-ao with the Archive property settings.

-AP set Internal compressed file path

-as the contents of a synchronized compressed file

-AV Apply user authentication information

-av-Disable adding user authentication information

-cfg-Ignore default configuration and environment variables

-CL convert file name to lowercase

-cu convert file name to uppercase

Delete compressed files after-DF compression

-DH Open a shared file

-ds files that are not sorted compressed

-ed does not add empty folders

-en do not add the "End of compressed file" block

-EP exclude a path from the name

-EP1 Exclude the home folder from the name

-EP2 expanded into full path

-EP3 extension contains the full path of the letter

-e[+]< Properties > Setting file exclusion and Inclusion properties

-F Refresh File

-hp[Password] Encrypt file data and headers

-ibck running in the background WinRAR

-ieml use e-mail to send compressed files

-iicon< name > Specify self-extracting icon

-iimg< name > Specify self-extracting picture

-ilog[Name] Log error to file

-inul Turn off error messages

-ioff Turn off PC power

-K Lock Compressed file

-KB keep the broken uncompressed file

-M set compression mode

-mc< Parameters > Setting Advanced compression parameters

-MD Select dictionary size

-ms Specify file storage

-n< files > contains only the specified files

-n@< List File > Use specified list file to include files

-os Save NTFS data stream

-oc Set NTFS Compressed property

-ow Processing file user identity check information

-o+ overwrite files that already exist

-o-do not overwrite files that already exist

-p[Password] Set password

-R back to subfolders

-r0 only returns subfolders that match wildcard characters

-ri setting priority and hibernation time

-RR[N] Add Data Recovery records

-rv[n] Create a recovery volume

-S to create solid compressed files

-S to create solid group in number of files

-SE Create solid group with file name extension

-sfx[Name] Create self-extracting file

-SV Create a solid compressed file that is not dependent

-sv-to create mutually dependent solid compacted files

-s-disabled solid-Real algorithm

-T after compressed test file

-ta< date > Only files modified after a specified date

-tb< date > Only files modified before the specified date

-TK Keep Original Compressed file time

-TL compressed file time with the latest file settings

-tn< time > process files that are newer than the specified time

-to< time > Handling files older than the specified time

-ts

-U update file

-V [k|b|f|m| M|g| G] Create a volume compression

-VD to erase disk content before you create a volume compression

-ver file Version control

-VN use the old style of the volume naming law

-VP pause before each volume is compressed

-x< file > exclude specified files

-x@< file list > Use the specified list file to exclude the specified file

-Y Suppose that all inquiries are answered "yes"

-z< file > Read compressed file comments from File

--Stop the scan of the switch

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.