Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2014-04-26
5
Medium Priority
?
1,550 Views
Last Modified: 2014-05-01
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 !
0
Comment
Question by:Md Shah
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 83

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.
0
 
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.
0
 
LVL 8

Accepted Solution

by:
Md Shah earned 0 total points
ID: 40025301
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
 
LVL 83

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
0
 
LVL 8

Author Closing Comment

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

Thanks.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

609 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