Exemplo n.º 1
0
        public void TryOpen()
        {
            CreateTestWorkbook("foo");
            OfficeCryptoStream ocs;

            Assert.IsFalse(OfficeCryptoStream.TryOpen(TestFile, null, out ocs));
            Assert.IsFalse(OfficeCryptoStream.TryOpen(TestFile, "bar", out ocs));
            Assert.IsTrue(OfficeCryptoStream.TryOpen(TestFile, "foo", out ocs));
            ocs.Close();
        }
Exemplo n.º 2
0
        public static OfficeCryptoStream OpenPasswordProtectedFile(String file)
        {
            String             password = null;
            OfficeCryptoStream stream   = null;

            while (OfficeCryptoStream.TryOpen(file, password, out stream) == false)
            {
                // Replace with your own input method (e.g. a dialog box)
                Console.Write("Enter password: ");
                password = Console.ReadLine();
            }
            return(stream);
        }