C# code to convert a .CSV file to .rar file

Posted on 2014-04-26
Medium Priority
Last Modified: 2014-05-01

In my project, i need to check the size of .csv file and if it exceeds 5MB then I need to covert that into a .RAR file.

Please let me know how i can achieve this.

Thanks in advance !
Question by:Md Shah
  • 2
  • 2
LVL 85

Assisted Solution

by:David Johnson, CD, MVP
David Johnson, CD, MVP earned 400 total points
ID: 40025052
you will have to use the command lines for winrar as it is closed source and no api's are available.  compressing it with zip is easily attainable.
LVL 40

Assisted Solution

by:Jacques Bourgeois (James Burger)
Jacques Bourgeois (James Burger) earned 1600 total points
ID: 40025227
.rar is not the only way to compress data. And the framework has what you need.

Look for the System.IO.Compression Namespace in the documentation, and you will find a few classes that deal with file compression and decompression, with examples of how to use them.

Accepted Solution

Md Shah earned 0 total points
ID: 40025301
As you said, I have went through MSDN link for System.IO.Compression reference:

I have written simple code to covert to zip file using above.

Now I have tried by changing the extension of destination file to .rar.

code to convert a file to .rar file
Thats it.. It has done the trick for me.. I can now convert a file to rar file.. :)
LVL 85

Expert Comment

by:David Johnson, CD, MVP
ID: 40025305
Except that it ISN'T a winrar archive but a zip archive. Sorta like calling a .png a .jpg

Author Closing Comment

by:Md Shah
ID: 40034115
I have mentioned about additional information in my last comment only.


Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Planning to migrate your EDB file(s) to a new or an existing Outlook PST file? This video will guide you how to convert EDB file(s) to PST. Besides this, it also describes, how one can easily search any item(s) from multiple folders or mailboxes…
From store locators to asset tracking and route optimization, learn how leading companies are using Google Maps APIs throughout the customer journey to increase checkout conversions, boost user engagement, and optimize order fulfillment. Powered …

597 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question