This project is read-only.

Archive Lock in process

Jun 18, 2014 at 3:53 PM
I make a software using the SevenZipCompressor to compress a folder and in the same process I want to push the .7z.001 file to Microsoft Azure online account and I hit a error about the file is locked by a another software.

This the code I write to compress :
        SevenZipCompressor fSevenZipCompressor = new SevenZipCompressor{
                                                                           IncludeEmptyDirectories = true,
                                                                           DirectoryStructure = true,
                                                                           ArchiveFormat = OutArchiveFormat.SevenZip, 
                                                                           VolumeSize = 2147483647 // 2 * 1024 * 1024 * 1024 - 1; 2GB
                                                                       };
// ReSharper disable AccessToStaticMemberViaDerivedType : Note add suppression option because with the base class doesn't work
        SevenZipCompressor.SetLibraryPath(Application.StartupPath + (Environment.Is64BitOperatingSystem ? @"\7z64.dll" : @"\7z.dll"));
// ReSharper restore AccessToStaticMemberViaDerivedType
        fSevenZipCompressor.CompressionMode = !File.Exists(fOutputFileName) ? CompressionMode.Create : CompressionMode.Append;
        fSevenZipCompressor.ScanOnlyWritable = true;
        fSevenZipCompressor.CompressDirectory(aFolderName, fOutputFileName, true);

After when I try to make a File.OpenRead(fOuputFileName) I have a Exception :
"The process cannot access the file 'C:\Test\ZipFiles.7z.001' because it is being used by another process."
__" at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)\r\n at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)\r\n at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy)\r\n at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)\r\n at System.IO.File.OpenRead(String path)\r\n at Opto.OptoSys.Manager.Tasks.FullBackupManagerTask.UploadOnLine(String aFileName, String aOSINumber, String aDayOfTheWeek) in C:\DEV\cs\Optosys2\server\manager\src\opto\optosys\manager\tasks\FullBackupManagerTask.cs:line 172"