c# - SevenZipSharp code does not work an no exception raised -


i using c# , trying use 7z encrypt single file new output archive.

i succeeded in encrypting whole folder not file. here code not work (i.e. after running code output directory has no .7z file , no exceptions raised ever!)

my archiving class looks this:

class class1 {     public static int compressfileto7zip(string sourcefile, string destinationfile)     { // takes sourcefile , encrypt password destinationfile         //try         //{         //console.writeline("compressfileto7zip source file = " + sourcefile);         sevenzipcompressor mycompressor = new sevenzipcompressor();         mycompressor.directorystructure = true;         mycompressor.archiveformat = outarchiveformat.sevenzip;         sevenzipcompressor.setlibrarypath(@"7z.dll");          mycompressor.compressionmethod = compressionmethod.lzma;         mycompressor.encryptheaders = true;         mycompressor.includeemptydirectories = true;         mycompressor.volumesize = 15000000; // 15 mb segment         mycompressor.compressionmode = compressionmode.create;         mycompressor.tempfolderpath = system.io.path.gettemppath();          string mypassword = "2hm3m3c2rkgkcjxyw7ugqhzh2ebeznm5ev"; // yes hardcoded ,just debugging         // compress password         mycompressor.compressfilesencrypted(destinationfile,mypassword, sourcefile );         //mycompressor.compressfiles(destinationfile, sourcefile); // no output !!         return 1;         //}         //catch (sevenziplibraryexception ex)         //{         //   console.writeline("7zip 2nd merror message= " + ex.message);         //   return -1; // error occured ,return indication of         //}        } } 

and call button click so:

private void button1_click(object sender, eventargs e)         {             class1.compressfileto7zip(@"d:\ddd.doc", @"d:\eee.7z");         } 

the file d:\ddd.doc exist.

just sake of completeness include code work archiving directories:

public static int sourcedirectorytofirstzipfile(string sourcedirectory, string destinationzip) {     try     {         sevenzipcompressor mycompressor = new sevenzipcompressor();         mycompressor.directorystructure = true;         mycompressor.archiveformat = outarchiveformat.sevenzip;         mycompressor.compressionmethod = compressionmethod.lzma;         mycompressor.encryptheaders = true;         mycompressor.includeemptydirectories = true;         sevenzipcompressor.setlibrarypath(@"7z.dll");          mycompressor.compressionmode = compressionmode.create;         mycompressor.tempfolderpath = system.io.path.gettemppath();          string mypassword = "j4jkds98wlef04fw8nsfvi8svd9fwemjk"; //just debugging         // compress password         mycompressor.compressdirectory(sourcedirectory, destinationzip, mypassword);         return 1;     }     catch(sevenziplibraryexception ex)     {         console.writeline("7zip 1st merror message= " + ex.message);         return -1; // error occured ,return indication of     } }  

may hels when attacht according events:

mycompressor.compressionfinished += mycompressoroncompressionfinished; mycompressor.filecompressionstarted += mycompressoronfilecompressionstarted; mycompressor.compressing += mycompressoroncompressing; 

they can more information.

hope helps.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -