Solved

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

Posted on 2014-04-26
5
1,342 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
Comment Utility
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
Comment Utility
.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
Comment Utility
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
Comment Utility
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
Comment Utility
I have mentioned about additional information in my last comment only.

Thanks.
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

744 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

17 Experts available now in Live!

Get 1:1 Help Now