2

Closed

Exception when file in use

description

Reproduce:
 
1) Somehow make a file become "in-use" by another process (however you want)
2) Using SevenZip.SevenZipCompressor execute the BeginCompressFiles(string, string[]) method
 
A SevenZipSharp exception is returned. While I believe the proper way to handle a file being in use is via throwing an exception, I would expect an exception from System.IO not the generic SevenZipSharp exception. This would allow proper handling as we can determine it is due to IO.
Closed Oct 27, 2010 at 6:09 AM by markhor
Well, since the exception is thrown, closing this

comments

lucasnodine wrote Oct 6, 2010 at 7:24 PM

After some checking, it does appear that the InnerException property contains an UnauthorizedAccessException in such case. As such, I now believe this should be marked "by design".

See below Log for details:

****** Exception Logging ******
ExceptionType: TargetInvocationException
HelpLine:
Message: Exception has been thrown by the target of an invocation.
Source: mscorlib
StackTrace: at System.RuntimeMethodHandle._InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeType typeOwner)
at System.RuntimeMethodHandle.InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeType typeOwner)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
at SevenZip.SevenZipBase.AsyncCallbackMethod(IAsyncResult ar)
at System.Runtime.Remoting.Messaging.AsyncResult.SyncProcessMessage(IMessage msg)
at System.Runtime.Remoting.Messaging.StackBuilderSink.AsyncProcessMessage(IMessage msg, IMessageSink replySink)
at System.Runtime.Remoting.Proxies.AgileAsyncWorkerItem.DoAsyncCall()
at System.Runtime.Remoting.Proxies.AgileAsyncWorkerItem.ThreadPoolCallBack(Object o)
at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
at System.Threading.ThreadPoolWorkQueue.Dispatch()
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()
TargetSite: System.Object _InvokeMethodFast(System.IRuntimeMethodInfo, System.Object, System.Object[], System.SignatureStruct ByRef, System.Reflection.MethodAttributes, System.RuntimeType)
****** Inner Exception ******
ExceptionType: UnauthorizedAccessException
HelpLine: 
Message: Access to the path 'Y:\Criminal\Ard, Ashley Lynn\10CR39PA\Photos\IMG_0908.jpg' is denied.
Source: mscorlib
StackTrace: 
Server stack trace:
at SevenZip.SevenZipBase.ThrowException(CallbackBase handler, Exception[] e)
at SevenZip.SevenZipBase.CheckedExecute(Int32 hresult, String message, CallbackBase handler)
at SevenZip.SevenZipCompressor.CompressFilesEncrypted(Stream archiveStream, Int32 commonRootLength, String password, String[] fileFullNames)
at SevenZip.SevenZipCompressor.CompressFilesEncrypted(String archiveName, Int32 commonRootLength, String password, String[] fileFullNames)
at SevenZip.SevenZipCompressor.CompressFilesEncrypted(String archiveName, String password, String[] fileFullNames)
at SevenZip.SevenZipCompressor.CompressFiles(String archiveName, String[] fileFullNames)
at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs)
at System.Runtime.Remoting.Messaging.StackBuilderSink.AsyncProcessMessage(IMessage msg, IMessageSink replySink)

Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.EndInvokeHelper(Message reqMsg, Boolean bProxyCase)
at System.Runtime.Remoting.Proxies.RemotingProxy.Invoke(Object NotUsed, MessageData& msgData)
at SevenZip.SevenZipCompressor.CompressFiles1Delegate.EndInvoke(IAsyncResult result)
TargetSite: System.Runtime.Remoting.Messaging.IMessage EndInvokeHelper(System.Runtime.Remoting.Messaging.Message, Boolean)

mwpowellhtx wrote May 25, 2012 at 6:32 PM

Pardon my ignorance, but, I am running into the same issue. I have permission to work with the files. I am an Administrator, in fact Domain Admin. So why the error?

mwpowellhtx wrote May 25, 2012 at 6:39 PM

Okay, did some poking around, and apparently when the VolumeSize is so small (like 1024), it causes that issue. I amped it up to something more like 8192 * 1024 (8K) and it works.