file - C# relative Filepath encrypt -




i want encrypt file relative file. use code encryption.

private void encryptfile(string inputfile, string outputfile) {     try     {         string password = @"cortex98";         unicodeencoding ue = new unicodeencoding();         byte[] key = ue.getbytes(password);          string cryptfile = outputfile;         filestream fscrypt = new filestream(cryptfile, filemode.create);          rijndaelmanaged rmcrypto = new rijndaelmanaged();          cryptostream cs = new cryptostream(fscrypt,             rmcrypto.createencryptor(key, key),             cryptostreammode.write);          filestream fsin = new filestream(inputfile, filemode.open);          int data;         while ((data = fsin.readbyte()) != -1)             cs.writebyte((byte)data);           fsin.close();         cs.close();         fscrypt.close();     }     catch     {         messagebox.show("encryption failed!", "error");     } } 

when use absolute path like:

encryptfile(@"c:\mov\input.mp4",@"c:\mov\output.mp4"); 

its works successfully. when use:

string inputrelative = @".\mov\input.mp4"; string outputrelative= @".\mov\output.mp4"; string input = path.getfullpath(inputrelative); string output = path.getfullpath(outputrelative); encryptfile(input,output); 

this returns encryption failed! error

an unhandled exception of type 'system.io.directorynotfoundexception' occurred in mscorlib.dll additional information: not find part of path 'c:\users\qsk\desktop\finform\cortexform\bin\debug\lib\corte‌​x\vcom.cortex





wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -