Create an RTF file with a name that matches the 7Zip file and open it when the List to Clipboard menu option is pressed. This will only happen if the Zip file is created.

This commit is contained in:
Rich 2013-03-14 19:32:42 +00:00
parent 68aa54004a
commit be014b12b3

View File

@ -222,12 +222,20 @@ namespace Sync
}
BuildZipOfMailBox(tbMailBox.Text);
}
private string _RTFFile = null;
public string RTFFile
{
get { return _RTFFile; }
set { _RTFFile = value; }
}
private void BuildZipOfMailBox(string mailbox)
{
SevenZipCompressor.SetLibraryPath(Application.StartupPath + @"\7z.dll");
SevenZipCompressor cmpr = new SevenZipCompressor();
cmpr.PreserveDirectoryRoot = true;
string zipName = string.Format("{0} To SS {1}.7z", mailbox, DateTime.Now.ToString("yyyyMMdd HHmm"));
string fileDate = DateTime.Now.ToString("yyyyMMdd HHmm");
RTFFile = string.Format("{0} To SS {1}.Rtf", mailbox, fileDate);
string zipName = string.Format("{0} To SS {1}.7z", mailbox, fileDate);
cmpr.CompressDirectory(mailbox, zipName, "*.*", true);
MessageBox.Show(string.Format("{0} created!", zipName), "Mailbox Zip Created", MessageBoxButtons.OK, MessageBoxIcon.Information);
@ -500,7 +508,13 @@ namespace Sync
dao.SetData(DataFormats.Text,sb.ToString());
dao.SetData(DataFormats.Rtf, rtb.Rtf);
Clipboard.SetDataObject(dao, true, 10, 500);
MessageBox.Show(sb.ToString(), "Copied to Clipboard", MessageBoxButtons.OK, MessageBoxIcon.Information);
if (RTFFile != null)
{
rtb.SaveFile(RTFFile);
System.Diagnostics.Process.Start(RTFFile);
}
else
MessageBox.Show(sb.ToString(), "Copied to Clipboard", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception ex)
{