Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Friends
I am VB.NET Programmer and currently working on a project where i have to copy the rar/zip file from any folder.
While pasting it, it should extract the rar/zip contents automatically.
I am done with my extracting part but

Here are some problems i am facing

Problem 1 : How should i detect that a rar/zip file is copied by the system ?

Problem 2 : How to track the file in which it has to be paste ?
All operation will be done from system context menu.

Kindly Help me Thank You
Posted

1 solution

RAR is proprietary; I would not advise to use it, but — please see below, you can always un-RAR.

Problem 1:

If you really need to detect the event like that, it may mean that your architecture seriously needs rethinking. If you still think you need go this way, the solution is to use the class System.IO.FileSystemWatcher:
http://msdn.microsoft.com/en-us/library/system.io.filesystemwatcher.aspx[^].

It's use can be problematic though; please see these CodeProject articles:
FileSystemWatcher - Pure Chaos (Part 1 of 2)[^],
FileSystemWatcher - Pure Chaos (Part 2 of 2)[^].

I would not advise you to get into it but would rather advise to review the architecture, but decide by yourself; I don't know your goals. (That's why this is a good idea to share them first when asking your questions.)

To work with just ZIP, you can use #ziplib:
http://www.icsharpcode.net/opensource/sharpziplib/[^].

Another option is using SevenZipSharp, a .NET wrapper of the famous 7-Zip:
http://en.wikipedia.org/wiki/7-Zip[^],
http://sevenzipsharp.codeplex.com/[^].

7-zip does support ZIP, RAR and a lot more.

Both libraries are open-source.

Problem 2:

It does not seem to make sense. Compression is not related to Past. If your code pastes, you don't need to "track" anything, your call can trigger whatever you want. If you want to capture Paste event, you need to understand what are you pasting; again, it has nothing to do with file compression. Perhaps I did not understand this part, but you certainly did not explain it properly.

—SA
 
Share this answer
 
v3
Comments
Kumar_G 7-Mar-13 7:56am    
I want to know how does the system knows that a rar/zip file has been copied ?
So that i can implement in my context menu
Sergey Alexandrovich Kryukov 7-Mar-13 12:46pm    
As I explained, FileSystemWatcher. Is that clear now?
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900