Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How to  Rar and UnRar the files in c#.net

Posted on 2009-04-15
5
Medium Priority
?
3,929 Views
Last Modified: 2013-12-17
Hi ,

           I need a code for how to Rar and UnRar the files in c#.net(without Chilkat Software)
0
Comment
Question by:dilipsjain
  • 2
  • 2
5 Comments
 

Expert Comment

by:HuntedBounty
ID: 24154838
So you dont want to use Chitkat?
But are you willing to use a component?

Heres a good one lets you Rar/Unrar and even Rar to your own desired file extention.

http://www.componentace.com/zipforge-transactions-in-c-sharp.htm

I've used the Delphi edition of it. and its really good.

Hope this helps :)
0
 
LVL 8

Accepted Solution

by:
dampsey earned 1500 total points
ID: 24154842
place rar32.exe and rsx.exe to a folder.
lets name it as ExeFolder (variable name in c#)

newFileNameWithFullPath is the file that will be created.
i.e. c:\someFolder\rared\myfiles.rar

fileToCompressWithFullPath is the file that will be rared.
i.e. c:\someanotherfolder\files\document001.doc
string arguments = " a -ep \"" + newFileNameWithFullPath + "\" \"" + fileToCompressWithFullPath + "\"";
            ProcessStartInfo inf = new ProcessStartInfo(ExeFolder + "\\rar32.exe", arguments);
            inf.WorkingDirectory = ExeFolder + "\\";
            inf.WindowStyle = ProcessWindowStyle.Hidden;
 
            Process islem = new Process();
            islem.StartInfo = inf;
            islem.Start();
            islem.WaitForExit();

Open in new window

0
 

Expert Comment

by:HuntedBounty
ID: 24154879
Well it would be easier to use zipforge, because the procedures (voids in C#) are ready made for you to use, just 3 lines of code can RAR a file and compress it ;)
0
 

Author Comment

by:dilipsjain
ID: 24155832

Hi dampsey ,

                     Thank you for ur reply . I have export.rar file  in  this path "D:\Web\VENUS\MINERVA\UPLOADFILES\export.rar" .This rar file having five txt files. I have to unrar that five text file to this path   "D:\Web\VENUS\MINERVA\OLD\" . I copied that unrar.exe in my web application(SANDS). i didnt created any folder, directly i added to (D:\softworkingfolder\SANDS\)
 I used ur code , its running fine without error but txt files are extracting to  "D:\Web\VENUS\MINERVA\OLD\"

   string arguments = " a -ep \"" + @"D:\Web\VENUS\MINERVA\OLD\" + "\" \"" + @"D:\Web\VENUS\MINERVA\UPLOADFILES\export.rar" + "\"";
            ProcessStartInfo inf = new ProcessStartInfo("UnRAR.exe", arguments);
            inf.WorkingDirectory = @"D:\softworkingfolder\SANDS\" + "\\";
            inf.WindowStyle = ProcessWindowStyle.Hidden;

            Process islem = new Process();
            islem.StartInfo = inf;
            islem.Start();
            islem.WaitForExit();
0
 

Author Comment

by:dilipsjain
ID: 24155865
Hi dampsey ,

                          Sorry one mistake in my last comment.,
 its running fine without error but txt files are NOT extracting to  "D:\Web\VENUS\MINERVA\OLD\"
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

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

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses
Course of the Month20 days, 16 hours left to enroll

810 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