Click here to Skip to main content
15,899,603 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi there,

I'm trying to zip a csv file to the C drive. I have a method that gets the Sales.csv file and it saves the csv file to the C drive but then when I use this code to zip it, it doesn't work. please assist what am I missing :-(
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();


Regards,
Graduate
Posted
Updated 29-Sep-10 0:05am
v2

Rather than try to kick off an external application (which may or may not be present, up to date and working ok) use C# libraries instead. Either Google for "Zip file in c#" or look at MSDN here[^]
 
Share this answer
 
Comments
JGraduate 29-Sep-10 6:10am    
Reason for my vote of 5
Automatic vote of 5 for accepting answer.
JGraduate 30-Sep-10 1:53am    
Thanks but that didnt help because I'm using Winzip Pro.
Toli Cuturicu 1-Oct-10 17:36pm    
So? Stop using it. Few people have it installed on their computers.
In addition to OriginalGriff's answer you can also try Sharpziplib[^]
 
Share this answer
 
v2
Could it be that you're missing a backslash here:

ps.Arguments = @"C:\Sales\" + dr["dbkey"].ToString() + ".csv";

???

Try debugging the Arguments value and see that it is really the valid path to the file you want to zip

Apart from that, this is a good zip library that can be used directly from .NET:

ZipStorer - A Pure C# Class to Store Files in Zip[^]
 
Share this answer
 
Comments
JGraduate 30-Sep-10 1:56am    
Hi,
No I'm not missing anything there that is just the name of the file and the ID so that the will be no duplicate when I save multiple files.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900