Example #1
0
        public override bool RunBody(State state)
        {
            RequirePropertyHandlerRegistered();
            RequireExtHasHandler();

#if x86
            const string cval = "ccomment***";

            //Create a temp file to put metadata on
            string fileName = CreateFreshFile(1);

            // Use DSOFile to set the value
            var dso = new DSOFile.OleDocumentProperties();
            dso.Open(fileName);
            var sum = dso.SummaryProperties;
            sum.Comments = cval;
            dso.Save();
            dso.Close();
            Marshal.ReleaseComObject(dso);  // preempt GC for CCW

            string svalue = null;

            var handler = new CPropertyHandler();
            handler.Initialize(fileName, 0);

            PropVariant value = new PropVariant();
            handler.GetValue(new TestDriverCodePack.PropertyKey(new Guid("F29F85E0-4FF9-1068-AB91-08002B27B3D9"), 6), value);
            svalue = (string)value.Value;

            Marshal.ReleaseComObject(handler); // preempt GC for CCW

            File.Delete(fileName);             // only works if all have let go of the file

            return(svalue == cval);
#else
            state.RecordEntry("Test skipped because DSOFile is 32-bit only");
            return(true);
#endif
        }
Example #2
0
        private void btDecrypt_Click(object sender, EventArgs e)
        {
            string fileName = "";
            string SSN      = "";

            if (tbDirectory.Text.Trim().Equals(""))
            {
                if (fBrowser.ShowDialog() == DialogResult.OK)
                {
                    this.tbDirectory.Text = fBrowser.SelectedPath;
                    this.tbDirectory.Refresh();
                }
            }
            // directory is still empty
            if (tbDirectory.Text.Trim().Equals(""))
            {
                MessageBox.Show("No directory selected!");
            }
            else
            {
                // cleanup text box
                if (!(this.tbDirectory.Text.Trim().EndsWith("\\")))
                {
                    this.tbDirectory.Text = this.tbDirectory.Text + "\\";
                    this.tbDirectory.Refresh();
                }


                curDir = new DirectoryInfo(this.tbDirectory.Text);

                //MessageBox.Show(curDir.ToString());
                //Create the OleDocumentProperties object.
                DSOFile.OleDocumentProperties dso = new DSOFile.OleDocumentProperties();

                theFiles = curDir.GetFiles("*.D*9", SearchOption.AllDirectories);

                //MessageBox.Show(theFiles.ToString());

                int total   = theFiles.Count();
                int current = 0;

                foreach (FileInfo fi in theFiles)
                {
                    //MessageBox.Show(fi.Directory.ToString());

                    current += 1;
                    //MessageBox.Show(fi.ToString());
                    fileName = @"" + fi.Directory.ToString() + "//" + fi.ToString().Trim();
                    lastdate = fi.LastWriteTime;
                    //fileName = @"" + this.tbDirectory.Text + fi.ToString().Trim();
                    //Open the file for writing if we can. If not we will get an exception.
                    try
                    {
                        dso.Open(fileName, false, DSOFile.dsoFileOpenOptions.dsoOptionOpenReadOnlyIfNoWriteAccess);
                    }
                    catch
                    {
                        MessageBox.Show("Threw an exception " + fileName);
                    }

                    lblResults.Text = "Current File Name:  " + fi.ToString();
                    lblResults.Refresh();
                    lblTime.Text = "File " + System.Convert.ToString(current) + " of " + System.Convert.ToString(total);
                    lblTime.Refresh();

                    // truncate the file name
                    fileName = fi.ToString().Substring(0, 8);

                    // convert to an SSN
                    SSN = getSSN(fileName);

                    //Set the summary properties that you want.
                    dso.SummaryProperties.Title = SSN;
                    //lastdate = dso.SummaryProperties.DateLastSaved.ToString();

                    //dso.SummaryProperties.Title = "dog";
                    //Save the Summary information.
                    dso.Save();
                    //Close the file.
                    dso.Close(false);
                    fi.LastWriteTime = lastdate;
                }

                lblResults.Text = "Finished";
                lblResults.Refresh();
            }
        }