So I am attempting to code a script in C# VS Studio 2019, where a user inputs which file to encrypt using 7zip and choose their password etc, using string to decide a password and which file to encrypt. It will save to the c:\ drive as "encryptedfilehere.7z". The problem is I'm struggling to format the code correctly:
private string button2_Click(object sender, EventArgs e)
{
MessageBox.Show("Assuming 7-zip is installed in C:\\Program Files\\7-Zip\\. If error message appears 7-zip is not installed in this driectory, it needs to be so.");
string sourceName = textBox1.Text;
string targetName = "c:\\encryptedmessagehere.7z";
// 1
// Initialize process information.
//
ProcessStartInfo p = new ProcessStartInfo();
p.FileName = "C:\\Program Files\\7-Zip\\7z.exe";
// 2
// Use 7-zip
// specify a=archive and -tgzip=gzip
// and then target file in quotes followed by source file in quotes
//
p.Arguments = "a -tgzip \"" + targetName + "\" \"" + sourceName + "\\" Form2.verify;
p.WindowStyle = ProcessWindowStyle.Hidden;
// 3.
// Start process and wait for it to exit
//
Process x = Process.Start(p);
x.WaitForExit();
}
The password is Form2.verify because it takes the password the user entered in another form via the string called verify. The errors returned are:
Error CS0161 'Form7.button2_Click(object, EventArgs)': not all code paths return a value
For using Form2.verify as the password:
Error CS0201 Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement ByteOribtPrivacyCannon C:\Users\keife\Downloads\ByteOrbitPrivacyCannon (2)\UniveralWindowsTextPGP\UniveralWindowsTextPGP\Form7.cs 48 Active
Any help is appreciated, thank you.