c# Create Zip File Using 7-zip

d:\s 폴더 안에 있는 모든 파일 (서브디렉토리포함) zip파일 형태로 압축하여 d\s.kmz 파일로 떨군다.
Creating "d\s.kmz" file from all files including sub folders in "d\s".

7zip Option : -t[Type]



public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string directoryName = Path.GetDirectoryName( System.Reflection.Assembly.GetExecutingAssembly().Location);

            string processName = Path.Combine( directoryName,"7z.exe");
            string argument = " a -tZip \"d:\\s.kmz\" \"d:\\s\\*\"";

            Process p = new Process();

            p.StartInfo.Arguments = argument;
            p.StartInfo.FileName = processName;
            p.StartInfo.CreateNoWindow = true;
            p.StartInfo.RedirectStandardOutput = true;
            p.StartInfo.RedirectStandardError = true;
            p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
            p.StartInfo.UseShellExecute = false;

            p.Start();

            string output = p.StandardOutput.ReadToEnd();
            string error = p.StandardError.ReadToEnd();

            richTextBox1.AppendText(output);
            richTextBox1.AppendText(error);

        }
    }

댓글

이 블로그의 인기 게시물

Ubuntu Server에 GitLab 설치 Jenkins BlueOcean 연동 + MSBuild