Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

.NET - Using Shell function to unzip a file raises a security error

Posted on 2008-10-20
5
Medium Priority
?
230 Views
Last Modified: 2013-12-04
I have a FileSystemWatcher that watches for files in a directory.

When a zip file lands in there, i execute winzip 11 using the following command;

Shell("C:\Program Files\WinZip\WINZIP32.EXE -e " & FilePath & " C:\Unzipped\", AppWinStyle.Hide, True)

When this command executes, .NET does not fall over. Instead, a message pops up FROM WINZIP (not from .NET - no exception is raised);

"Could not open C:\Test.zip
Probable cause: file sharing or file permissions problem."

I need to be able to call winzip under the administrator account - which seems strange because this application runs under the administrator account.
0
Comment
Question by:tfsln
  • 3
  • 2
5 Comments
 
LVL 8

Accepted Solution

by:
MatthiasVance earned 2000 total points
ID: 22762839
Are you sure the file is fully written when your FileSystemWatcher fires the event?
It also fires when the file is created or during writes.
I suggest you try reading the file programmaticaly, if that succeeds, shell winzip again.

Kind regards,

Matthias Vance
0
 

Author Comment

by:tfsln
ID: 22762852
If the file has not yet been created, then how can i instruct the FileSystemWatcher to not report files until they are created?

If what your saying is correct, and it fails programmatically (which i suspect it will), then what would i do?
0
 
LVL 8

Expert Comment

by:MatthiasVance
ID: 22762914
If your program gets an IOException when trying to read the file you don't Shell() Winzip, otherwise, you do. I think this is safe because the FileSystemWatcher will fire another event when another block of the file (and possibly the last) is written. This time your read will succeed and it will run winzip.

Kind regards,

Matthias Vance
0
 

Author Comment

by:tfsln
ID: 22772902
Your original answer solved my problem.

I did some testing and just for your own information; the FileSystemWatcher does not raise the Created event on each block of the file written. It raises one event when the file is created (the event will fire even if the file isnt finished copying - which caused my problem).
0
 

Author Closing Comment

by:tfsln
ID: 31508064
Cheers mate.
0

Featured Post

WatchGuard Case Study: NCR

With business operations for thousands of customers largely depending on the internal systems they support, NCR can’t afford to waste time or money on security products that are anything less than exceptional. That’s why they chose WatchGuard.

Question has a verified solution.

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

This is a guide to the following problem (not exclusive but here) on Windows: Users need our support and we supporters often use global administrative accounts to do this. Using these accounts safely is a real challenge. Any admin who takes se…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

877 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