Solved

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

Posted on 2014-04-26
5
1,376 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
  • 2
  • 2
5 Comments
 
LVL 78

Assisted Solution

by:David Johnson, CD, MVP
David Johnson, CD, MVP earned 100 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 400 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 78

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
New to SOAP and need some direction 10 46
DateTimepicker 4 33
SSL https .net web site force redirect 3 37
Device Location 4 13
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

896 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now