How to zip a csv file

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Graduate
    New Member
    • Sep 2010
    • 7

    How to zip a csv file

    Hi Guys,

    I have a Sales.csv file that is sitting in the C drive I want to zip it in C# code this is the code that I used but it is not ziping the Sales.csv file.
    Please help!!!

    Code:
    ProcessStartInfo ps = new ProcessStartInfo();
                        ps.UseShellExecute = true;
                        ps.Arguments = @"C:\Sales" + dr["dbkey"].ToString() + ".csv";
                        
                        ps.FileName = "C:\\Program Files\\WinZip\\WZZIP.EXE";  
                        Process p = Process.Start(ps);
                        p.WaitForExit();
    Many thanks,
    Last edited by Niheel; Oct 1 '10, 07:10 AM.
  • TamusJRoyce
    New Member
    • Apr 2008
    • 108

    #2
    I've had good results using http://dotnetzip.codeplex.com/.

    And another one is http://sevenzipsharp.codeplex.com/, which 7zip is my main zip utility. I haven't used its api yet.

    I don't know about using winzip/winrar, but you would probably want a sdk's.

    >= .NET 3.0 has .zip compression library built-in, if you have licensing issues. It's located in System.IO.Packa ging.

    I think any choice you choose where you don't have to call an external executable is a better choice. But please comment again if you are doing this for learning purposes (be sure to state you need help based on ShellExecute).

    Comment

    • Graduate
      New Member
      • Sep 2010
      • 7

      #3
      Thanx for your help but I'm specifically told to use WinZip.

      Comment

      • TamusJRoyce
        New Member
        • Apr 2008
        • 108

        #4
        What does

        Console.WriteLi ne(@"C:\Sales" + dr["dbkey"].ToString() + ".csv");

        or

        MessageBox.Show (@"C:\Sales" + dr["dbkey"].ToString() + ".csv", ".csv to open");

        say? I see right off hand that C:\S... should be C:\\S...
        Last edited by Niheel; Oct 1 '10, 07:11 AM. Reason: added code tags

        Comment

        • Graduate
          New Member
          • Sep 2010
          • 7

          #5
          this ps.Arguments = @"C:\Sales" + dr["dbkey"].ToString() + ".csv"; is going to take Sales1.csv from the C drive the dbkey is to make the files unique so that the will be no duplicate when it generate csv files.

          if you put the @ it means that you dont have to put double qoutes.

          Comment

          Working...