Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8264845
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T04:36:05+00:00 2026-06-08T04:36:05+00:00

I am trying to zip some folders. They have different paths, will not belong

  • 0

I am trying to zip some folders. They have different paths, will not belong to the same directory.

I tested the command line arguments that I would give, and it works, but I can’t get it to work from c#:

string destination = "some path\\name.7z";
string pathToZip = "path to zip\\7z.exe";  // or 7za.exe
ProcessStartInfo p = new ProcessStartInfo();
p.FileName = pathToZip;
p.Arguments = "a \"" + destination + "\" \"";
// room for the foreach - but even one directory doesn't work right now
   p.Arguments += directoryPath + "\" \"";
p.Arguments += "\" -mx=9 -aoa";
Process x = Process.Start(p);

With 7z.exe i get a blink; With 7za.exe, I get the typical command-line zip sequence, with files zipping through, adding to archive, and an archive gets created.

Then I go to it and right-click, open or double-click… and I get that it is an invalid archive (Can not open file "name.7z" as an archive). Try command line, with 7za, to extract – same thing.

Edit: I found the solution:

My problem was the -aoa option (which I used for overwrite) – after removing it, it worked.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T04:36:07+00:00Added an answer on June 8, 2026 at 4:36 am

    This code works for me, packs a directory with files within:

    string destination = @"c:\my test.7z";
    string pathToZip = @"C:\Program Files\7-Zip\7z.exe";
    string directoryPath = @"c:\my test";
    
    ProcessStartInfo p = new ProcessStartInfo();
    p.FileName = pathToZip;
    p.Arguments = string.Format("a -mx=9 \"{0}\" \"{1}\"", destination, directoryPath);
    
    Process x = Process.Start(p);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to write an MsBuild script to zip some files up. I need
I am trying to get the zip code of the users current location.I have
I am trying to run a project from Github I do not have much
I'm trying to clean up some legacy code and have some unchecked cast warnings
I am trying to copy over some files pulled out from a zip folder,
I have a small problem with TFS. I am trying to zip files after
I am trying to unzip an archive (test.zip) containing a subfolder with some png
I am trying to script some code that will search a specified folder on
I am currently trying to zip all files within a directory. The zip file
For some reason when trying to upload a zip file this function always returns

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.