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