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

Hi,

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 !
LVL 8
Md ShahAsked:
Who is Participating?
 
Md ShahConnect With a Mentor Author Commented:
As you said, I have went through MSDN link for System.IO.Compression reference:
http://msdn.microsoft.com/en-us/library/vstudio/system.io.compression

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.. :)
0
 
David Johnson, CD, MVPConnect With a Mentor OwnerCommented:
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.
0
 
Jacques Bourgeois (James Burger)Connect With a Mentor PresidentCommented:
.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.
0
 
David Johnson, CD, MVPOwnerCommented:
Except that it ISN'T a winrar archive but a zip archive. Sorta like calling a .png a .jpg
0
 
Md ShahAuthor Commented:
I have mentioned about additional information in my last comment only.

Thanks.
0
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.

All Courses

From novice to tech pro — start learning today.