Exemplo n.º 1
0
      private static void DumpClassFileInfo(bool isLocal)
      {
         #region Setup

         Console.WriteLine("\n=== TEST {0} ===", isLocal ? Local : Network);
         string tempPath = Path.Combine(Path.GetTempPath(), "FileInfo()-" + Path.GetRandomFileName());
         if (!isLocal) tempPath = Path.LocalToUnc(tempPath);

         int expectedLastError;
         string expectedException;

         string nonExistingFile = SysRoot32 + @"\NonExistingFile-" + Path.GetRandomFileName();
         if (!isLocal) nonExistingFile = Path.LocalToUnc(nonExistingFile);

         string sysDrive = SysDrive;
         if (!isLocal) sysDrive = Path.LocalToUnc(sysDrive);

         string sysRoot = SysRoot;
         if (!isLocal) sysRoot = Path.LocalToUnc(sysRoot);

         string letter = DriveInfo.GetFreeDriveLetter() + @":\";
         if (!isLocal) letter = Path.LocalToUnc(letter);

         #endregion // Setup

         #region NotSupportedException

         expectedLastError = (int) (isLocal ? Win32Errors.ERROR_ENVVAR_NOT_FOUND : Win32Errors.NERR_UseNotFound);
         expectedException = "System.NotSupportedException";
         bool exception = false;
         try
         {
            Console.WriteLine("\nCatch: [{0}]: The given path's format is not supported.", expectedException);

            string invalidPath = SysDrive + @"\:a";
            if (!isLocal) invalidPath = Path.LocalToUnc(invalidPath) + @":a";

            FileInfo fi = new FileInfo(invalidPath);
         }
         catch (Exception ex)
         {
            // Not reliable.
            //var win32Error = new Win32Exception("", ex);
            //Assert.IsTrue(win32Error.NativeErrorCode == expectedLastError, string.Format("Expected Win32Exception error should be: [{0}], got: [{1}]", expectedLastError, win32Error.NativeErrorCode));
            //Assert.IsTrue(ex.Message.StartsWith("(" + expectedLastError + ")"), string.Format("Expected Win32Exception error is: [{0}]", expectedLastError));

            string exceptionTypeName = ex.GetType().FullName;
            if (exceptionTypeName.Equals(expectedException))
            {
               exception = true;
               Console.WriteLine("\n\t[{0}]: [{1}]", exceptionTypeName, ex.Message.Replace(Environment.NewLine, "  "));
            }
            else
               Console.WriteLine("\n\tCaught Unexpected Exception: [{0}]: [{1}]", exceptionTypeName, ex.Message.Replace(Environment.NewLine, "  "));
         }
         Assert.IsTrue(exception, "[{0}] should have been caught.", expectedException);
         Console.WriteLine();

         #endregion // NotSupportedException

         #region Length Property

         #region FileNotFoundException #1

         expectedLastError = (int) Win32Errors.ERROR_FILE_NOT_FOUND;
         expectedException = "System.IO.FileNotFoundException";
         exception = false;
         try
         {
            Console.WriteLine("\nCatch: [{0}]: Length property is called, the file does not exist.", expectedException);
            Console.WriteLine(new FileInfo(nonExistingFile).Length);
         }
         catch (Exception ex)
         {
            var win32Error = new Win32Exception("", ex);
            Assert.IsTrue(win32Error.NativeErrorCode == expectedLastError, string.Format("Expected Win32Exception error should be: [{0}], got: [{1}]", expectedLastError, win32Error.NativeErrorCode));
            Assert.IsTrue(ex.Message.StartsWith("(" + expectedLastError + ")"), string.Format("Expected Win32Exception error is: [{0}]", expectedLastError));

            string exceptionTypeName = ex.GetType().FullName;
            if (exceptionTypeName.Equals(expectedException))
            {
               exception = true;
               Console.WriteLine("\n\t[{0}]: [{1}]", exceptionTypeName, ex.Message.Replace(Environment.NewLine, "  "));
            }
            else
               Console.WriteLine("\n\tCaught Unexpected Exception: [{0}]: [{1}]", exceptionTypeName, ex.Message.Replace(Environment.NewLine, "  "));
         }
         Assert.IsTrue(exception, "[{0}] should have been caught.", expectedException);
         Console.WriteLine();

         #endregion // FileNotFoundException #1

         #region FileNotFoundException #2

         expectedLastError = (int) (isLocal ? Win32Errors.ERROR_PATH_NOT_FOUND : Win32Errors.ERROR_BAD_NET_NAME);
         expectedException = isLocal ? "System.IO.FileNotFoundException" : "System.IO.IOException";
         exception = false;
         try
         {
            Console.WriteLine("\nCatch: [{0}]: Length property is called, the file does not exist (Unmapped drive).", expectedException);

            Console.WriteLine(new FileInfo(nonExistingFile.Replace(sysDrive + @"\", letter)).Length);
         }
         catch (Exception ex)
         {
            var win32Error = new Win32Exception("", ex);
            Assert.IsTrue(win32Error.NativeErrorCode == expectedLastError, string.Format("Expected Win32Exception error should be: [{0}], got: [{1}]", expectedLastError, win32Error.NativeErrorCode));
            //Assert.IsTrue(ex.Message.StartsWith("(" + expectedLastError + ")"), string.Format("Expected Win32Exception error is: [{0}]", expectedLastError));

            string exceptionTypeName = ex.GetType().FullName;
            if (exceptionTypeName.Equals(expectedException))
            {
               exception = true;
               Console.WriteLine("\n\t[{0}]: [{1}]", exceptionTypeName, ex.Message.Replace(Environment.NewLine, "  "));
            }
            else
               Console.WriteLine("\n\tCaught Unexpected Exception: [{0}]: [{1}]", exceptionTypeName, ex.Message.Replace(Environment.NewLine, "  "));
         }
         Assert.IsTrue(exception, "[{0}] should have been caught.", expectedException);
         Console.WriteLine();

         #endregion // FileNotFoundException #1
         
         #region FileNotFoundException #3

         expectedLastError = (int) Win32Errors.ERROR_FILE_NOT_FOUND;
         expectedException = "System.IO.FileNotFoundException";
         exception = false;
         try
         {
            Console.WriteLine("\nCatch: [{0}]: Length property is called, the file is a directory.", expectedException);
            Console.WriteLine(new FileInfo(sysRoot).Length);
         }
         catch (Exception ex)
         {
            // win32Error is always 0
            //var win32Error = new Win32Exception("", ex);
            //Assert.IsTrue(win32Error.NativeErrorCode == expectedLastError, string.Format("Expected Win32Exception error should be: [{0}], got: [{1}]", expectedLastError, win32Error.NativeErrorCode));
            Assert.IsTrue(ex.Message.StartsWith("(" + expectedLastError + ")"), string.Format("Expected Win32Exception error is: [{0}]", expectedLastError));

            string exceptionTypeName = ex.GetType().FullName;
            if (exceptionTypeName.Equals(expectedException))
            {
               exception = true;
               Console.WriteLine("\n\t[{0}]: [{1}]", exceptionTypeName, ex.Message.Replace(Environment.NewLine, "  "));
            }
            else
               Console.WriteLine("\n\tCaught Unexpected Exception: [{0}]: [{1}]", exceptionTypeName, ex.Message.Replace(Environment.NewLine, "  "));
         }
         Assert.IsTrue(exception, "[{0}] should have been caught.", expectedException);
         Console.WriteLine();

         #endregion // FileNotFoundException #3

         #endregion // Length Property

         
         #region Current Directory

         tempPath = Path.CurrentDirectoryPrefix;
         if (!isLocal) tempPath = Path.LocalToUnc(tempPath);

         Console.WriteLine("\nInput File Path (Current directory): [{0}]\n", tempPath);

         StopWatcher(true);
         System.IO.FileInfo expected = new System.IO.FileInfo(tempPath);
         Console.WriteLine("\tSystem.IO FileInfo(){0}", Reporter());

         StopWatcher(true);
         FileInfo actual = new FileInfo(tempPath);
         Console.WriteLine("\tAlphaFS FileInfo(){0}", Reporter());

         // Compare values of both instances.
         CompareFileInfos(expected, actual);

         #endregion // Current Directory

         #region Non-Existing File

         Console.WriteLine("\nInput File Path: [{0}]\n", nonExistingFile);

         StopWatcher(true);
         expected = new System.IO.FileInfo(nonExistingFile);
         Console.WriteLine("\tSystem.IO FileInfo(){0}", Reporter());

         StopWatcher(true);
         actual = new FileInfo(nonExistingFile);
         Console.WriteLine("\tAlphaFS FileInfo(){0}", Reporter());

         // Compare values of both instances.
         CompareFileInfos(expected, actual);

         #endregion // Non-Existing File

         #region Existing File

         tempPath = Path.Combine(Path.GetTempPath(), "FileInfo()-File-" + Path.GetRandomFileName());
         if (!isLocal) tempPath = Path.LocalToUnc(tempPath);

         try
         {
            using (File.Create(tempPath)) {}

            Console.WriteLine("\nInput File Path: [{0}]\n", tempPath);

            StopWatcher(true);
            expected = new System.IO.FileInfo(tempPath);
            Console.WriteLine("\tSystem.IO FileInfo(){0}", Reporter());

            StopWatcher(true);
            actual = new FileInfo(tempPath);
            Console.WriteLine("\tAlphaFS FileInfo(){0}", Reporter());

            // Compare values of both instances.
            CompareFileInfos(expected, actual);
         }
         finally
         {
            File.Delete(tempPath);
            Assert.IsFalse(File.Exists(tempPath), "Cleanup failed: File should have been removed.");
         }

         #endregion // Existing File

         #region Method .ToString()

         Console.WriteLine("\nMethod .ToString()");
         Console.WriteLine("Both strings should be the same.\n");

         expected = new System.IO.FileInfo("ToString()-TestFile");
         actual = new FileInfo("ToString()-TestFile");

         string expectedToString = expected.ToString();
         string actualToString = actual.ToString();

         Console.WriteLine("\tSystem.IO: [{0}]", expectedToString);
         Console.WriteLine("\tAlphaFS  : [{0}]", actualToString);

         Assert.AreEqual(expectedToString, actualToString, false);
         Console.WriteLine();

         #endregion Method .ToString()
      }
Exemplo n.º 2
0
        private void DumpRefresh(bool isLocal)
        {
            #region Setup

            Console.WriteLine("\n=== TEST {0} ===", isLocal ? Local : Network);

            string tempPathSysIo = Path.GetTempPath("FileInfo.Refresh()-file-SysIo-" + Path.GetRandomFileName());
            string tempPath      = Path.GetTempPath("FileInfo.Refresh()-file-AlphaFS-" + Path.GetRandomFileName());
            if (!isLocal)
            {
                tempPathSysIo = Path.LocalToUnc(tempPathSysIo);
            }
            if (!isLocal)
            {
                tempPath = Path.LocalToUnc(tempPath);
            }

            Console.WriteLine("\nInput File Path: [{0}]", tempPath);

            #endregion // Setup

            #region Refresh

            try
            {
                System.IO.FileInfo fiSysIo = new System.IO.FileInfo(tempPathSysIo);
                FileInfo           fi      = new FileInfo(tempPath);

                bool existsSysIo = fiSysIo.Exists;
                bool exists      = fi.Exists;
                Console.WriteLine("\nnew FileInfo(): Exists (Should be {0}): [{1}]", existsSysIo, exists); // false
                Assert.AreEqual(existsSysIo, exists);

                FileStream fsSysIo = fiSysIo.Create();
                FileStream fs      = fi.Create();
                existsSysIo = fiSysIo.Exists;
                exists      = fi.Exists;
                Console.WriteLine("\nfi.Create(): Exists (Should be {0}): [{1}]", existsSysIo, exists); // false
                Assert.AreEqual(existsSysIo, exists);

                fiSysIo.Refresh();
                fi.Refresh();
                existsSysIo = fiSysIo.Exists;
                exists      = fi.Exists;
                Console.WriteLine("\nfi.Refresh(): Exists (Should be {0}): [{1}]", existsSysIo, exists); // true
                Assert.AreEqual(existsSysIo, exists);

                fsSysIo.Close();
                fs.Close();
                existsSysIo = fiSysIo.Exists;
                exists      = fi.Exists;
                Console.WriteLine("\nfi.Close(): Exists (Should be {0}): [{1}]", existsSysIo, exists); // true
                Assert.AreEqual(existsSysIo, exists);

                fiSysIo.Delete();
                fi.Delete();
                existsSysIo = fiSysIo.Exists;
                exists      = fi.Exists;
                Console.WriteLine("\nfi.Delete(): Exists (Should be {0}): [{1}]", existsSysIo, exists); // true
                Assert.AreEqual(existsSysIo, exists);

                fiSysIo.Refresh();
                fi.Refresh();
                existsSysIo = fiSysIo.Exists;
                exists      = fi.Exists;
                Console.WriteLine("\nfi.Refresh(): Exists (Should be False): [{0}]", exists); // false
                Assert.AreEqual(existsSysIo, exists);
            }
            finally
            {
                File.Delete(tempPath);
                Assert.IsFalse(File.Exists(tempPath), "Cleanup failed: File should have been removed.");

                File.Delete(tempPathSysIo);
                Assert.IsFalse(File.Exists(tempPath), "Cleanup failed: File should have been removed.");
                Console.WriteLine();
            }

            #endregion // Refresh
        }
Exemplo n.º 3
0
      public void SetAccessControl()
      {
         Console.WriteLine("File.SetAccessControl()");

         if (!IsAdmin())
            Assert.Fail();

         string path = SysDrive + @"\AlphaFile-" + Path.GetRandomFileName();
         string pathAlpha = path;

         Console.WriteLine("\n\tFile: [{0}]", path);

         try
         {
            using (File.Create(pathAlpha))
            {
            }

            // Initial read.
            Console.WriteLine("\n\tInitial read.");
            FileSecurity dsSystem = System.IO.File.GetAccessControl(path, AccessControlSections.Access);
            FileSecurity dsAlpha = File.GetAccessControl(pathAlpha, AccessControlSections.Access);
            AuthorizationRuleCollection accessRulesSystem = dsSystem.GetAccessRules(true, true, typeof(NTAccount));
            AuthorizationRuleCollection accessRulesAlpha = dsAlpha.GetAccessRules(true, true, typeof(NTAccount));
            Console.WriteLine("\t    System.IO.File.GetAccessControl() rules found: [{0}]", accessRulesSystem.Count);
            Console.WriteLine("\t\t\t   File.GetAccessControl() rules found: [{0}]", accessRulesAlpha.Count);
            Assert.AreEqual(accessRulesSystem.Count, accessRulesAlpha.Count);

            // Sanity check.
            DumpAccessRules(1, dsSystem, dsAlpha);

            // Remove inherited properties.
            // Passing true for first parameter protects the new permission from inheritance, and second parameter removes the existing inherited permissions 
            Console.WriteLine("\n\tRemove inherited properties and persist it.");
            dsAlpha.SetAccessRuleProtection(true, false);
            File.SetAccessControl(pathAlpha, dsAlpha, AccessControlSections.Access);

            // Re-read, using instance methods.
            System.IO.FileInfo fiSystem = new System.IO.FileInfo(Path.LocalToUnc(path));
            FileInfo fiAlpha = new FileInfo(Path.LocalToUnc(path));

            dsSystem = fiSystem.GetAccessControl(AccessControlSections.Access);
            dsAlpha = fiAlpha.GetAccessControl(AccessControlSections.Access);

            // Sanity check.
            DumpAccessRules(2, dsSystem, dsAlpha);

            // Restore inherited properties.
            Console.WriteLine("\n\tRestore inherited properties and persist it.");
            dsAlpha.SetAccessRuleProtection(false, true);
            File.SetAccessControl(pathAlpha, dsAlpha, AccessControlSections.Access);

            // Re-read.
            dsSystem = System.IO.File.GetAccessControl(path, AccessControlSections.Access);
            dsAlpha = File.GetAccessControl(pathAlpha, AccessControlSections.Access);

            // Sanity check.
            DumpAccessRules(3, dsSystem, dsAlpha);

            fiSystem.Delete();
            fiSystem.Refresh(); // Must Refresh() to get actual state.

            fiAlpha.Delete();
            fiAlpha.Refresh(); // Must Refresh() to get actual state.
            Assert.IsFalse(fiAlpha.Exists);
         }
         catch (Exception ex)
         {
            Console.WriteLine("\nCaught Exception: [{0}]\n", ex.Message.Replace(Environment.NewLine, "  "));
         }
      }
Exemplo n.º 4
0
      private void DumpRefresh(bool isLocal)
      {
         #region Setup

         Console.WriteLine("\n=== TEST {0} ===", isLocal ? Local : Network);

         string tempPathSysIo = Path.GetTempPath("FileInfo.Refresh()-file-SysIo-" + Path.GetRandomFileName());
         string tempPath = Path.GetTempPath("FileInfo.Refresh()-file-AlphaFS-" + Path.GetRandomFileName());
         if (!isLocal) tempPathSysIo = Path.LocalToUnc(tempPathSysIo);
         if (!isLocal) tempPath = Path.LocalToUnc(tempPath);

         Console.WriteLine("\nInput File Path: [{0}]", tempPath);

         #endregion // Setup

         #region Refresh

         try
         {
            System.IO.FileInfo fiSysIo = new System.IO.FileInfo(tempPathSysIo);
            FileInfo fi = new FileInfo(tempPath);

            bool existsSysIo = fiSysIo.Exists;
            bool exists = fi.Exists;
            Console.WriteLine("\nnew FileInfo(): Exists (Should be {0}): [{1}]", existsSysIo, exists); // false
            Assert.AreEqual(existsSysIo, exists);

            FileStream fsSysIo = fiSysIo.Create();
            FileStream fs = fi.Create();
            existsSysIo = fiSysIo.Exists;
            exists = fi.Exists;
            Console.WriteLine("\nfi.Create(): Exists (Should be {0}): [{1}]", existsSysIo, exists); // false
            Assert.AreEqual(existsSysIo, exists);

            fiSysIo.Refresh();
            fi.Refresh();
            existsSysIo = fiSysIo.Exists;
            exists = fi.Exists;
            Console.WriteLine("\nfi.Refresh(): Exists (Should be {0}): [{1}]", existsSysIo, exists); // true
            Assert.AreEqual(existsSysIo, exists);

            fsSysIo.Close();
            fs.Close();
            existsSysIo = fiSysIo.Exists;
            exists = fi.Exists;
            Console.WriteLine("\nfi.Close(): Exists (Should be {0}): [{1}]", existsSysIo, exists); // true
            Assert.AreEqual(existsSysIo, exists);

            fiSysIo.Delete();
            fi.Delete();
            existsSysIo = fiSysIo.Exists;
            exists = fi.Exists;
            Console.WriteLine("\nfi.Delete(): Exists (Should be {0}): [{1}]", existsSysIo, exists); // true
            Assert.AreEqual(existsSysIo, exists);
            
            fiSysIo.Refresh();
            fi.Refresh();
            existsSysIo = fiSysIo.Exists;
            exists = fi.Exists;
            Console.WriteLine("\nfi.Refresh(): Exists (Should be False): [{0}]", exists); // false
            Assert.AreEqual(existsSysIo, exists);
         }
         finally
         {
            File.Delete(tempPath);
            Assert.IsFalse(File.Exists(tempPath), "Cleanup failed: File should have been removed.");

            File.Delete(tempPathSysIo);
            Assert.IsFalse(File.Exists(tempPath), "Cleanup failed: File should have been removed.");
            Console.WriteLine();
         }

         #endregion // Refresh
      }
Exemplo n.º 5
0
      private void DumpFileTrailingDotSpace(bool isLocal)
      {
         Console.WriteLine("\n=== TEST {0} ===\n", isLocal ? Local : Network);
         const string characterDot = ".";
         const string characterSpace = " ";
         string random = Path.GetRandomFileName();
         string tempPathDot = Path.GetTempPath("File.Create()-" + random + "-file-with-dot-" + characterDot);
         string tempPathSpace = Path.GetTempPath("File.Create()-" + random + "-file-with-space-" + characterSpace);
         if (!isLocal) tempPathDot = Path.LocalToUnc(tempPathDot);
         if (!isLocal) tempPathSpace = Path.LocalToUnc(tempPathSpace);

         Console.WriteLine("Input File Path (with dot)  : [{0}]", tempPathDot);
         Console.WriteLine("Input File Path (with space): [{0}]", tempPathSpace);

         Assert.IsTrue(tempPathDot.EndsWith(characterDot), "Path should have a trailing dot.");
         Assert.IsTrue(tempPathSpace.EndsWith(characterSpace), "Path should have a trailing space.");

         #region Path.GetFullPath(), Path Normalization

         string sysIo = System.IO.Path.GetFullPath(tempPathDot);
         Assert.IsFalse(sysIo.EndsWith(characterDot), "Path should not have a trailing dot.");

         sysIo = System.IO.Path.GetFullPath(tempPathSpace);
         Assert.IsFalse(sysIo.EndsWith(characterSpace), "Path should not have a trailing space.");


         string alphaFs = Path.GetFullPath(tempPathDot);
         Assert.IsFalse(alphaFs.EndsWith(characterDot), "Path should not have a trailing dot.");

         alphaFs = Path.GetFullPath(tempPathSpace);
         Assert.IsFalse(alphaFs.EndsWith(characterSpace), "Path should not have a trailing space.");


         Assert.AreEqual(sysIo, alphaFs, "Paths should be the same.");

         #endregion // Path.GetFullPath(), Path Normalization

         #region Path.GetLongPath(), No Path Normalization

         alphaFs = Path.GetLongPath(tempPathDot);
         Assert.IsTrue(alphaFs.EndsWith(characterDot), "Path should have a trailing dot.");

         alphaFs = Path.GetLongPath(tempPathSpace);
         Assert.IsTrue(alphaFs.EndsWith(characterSpace), "Path should have a trailing space.");

         Assert.AreNotEqual(alphaFs, sysIo, "Paths should not be the same.");

         #endregion // Path.GetLongPath(), No Path Normalization

         #region Path.GetRegularPath(), No Path Normalization

         alphaFs = Path.GetRegularPath(tempPathDot);
         Assert.IsTrue(alphaFs.EndsWith(characterDot), "Path should have a trailing dot.");

         alphaFs = Path.GetRegularPath(tempPathSpace);
         Assert.IsTrue(alphaFs.EndsWith(characterSpace), "Path should have a trailing space.");

         Assert.AreNotEqual(alphaFs, sysIo, "Paths should not be the same.");

         #endregion // Path.GetRegularPath(), No Path Normalization

         Console.WriteLine();

         #region File() Class

         StopWatcher(true);

         #region TrailingDot

         #region System.IO

         // tempPathDot contains a trailing dot but gets stripped on path normalization.
         // System.IO handles the file without the trailing dot. Therefore, the file exists.
         // AlphaFS has the same behaviour as .NET for default methods.

         using (FileStream fs = System.IO.File.Create(tempPathDot)) { fs.WriteByte(1); }
         Assert.IsTrue(System.IO.File.Exists(tempPathDot), "File should exist.");
         Assert.IsTrue(File.Exists(tempPathDot), "File should be visible to AlphaFS.");
         Assert.IsFalse(File.Exists(tempPathDot, PathFormat.FullPath), "File should be invisible to AlphaFS.");

         using (StreamWriter sw = System.IO.File.AppendText(tempPathDot))
            sw.WriteLine(TextHelloWorld);

         string lineSysIo;
         using (StreamReader sr = System.IO.File.OpenText(tempPathDot))
            lineSysIo = sr.ReadToEnd();

         System.IO.File.Delete(tempPathDot);
         Assert.IsFalse(System.IO.File.Exists(tempPathDot), "File should not exist.");

         #endregion // System.IO

         #region AlphaFS

         using (FileStream fs = File.Create(tempPathDot, PathFormat.FullPath)) { fs.WriteByte(1); } // Create file without path normalization.
         Assert.IsTrue(File.Exists(tempPathDot, PathFormat.FullPath), "File should exist and visible to AlphaFS.");
         Assert.IsFalse(System.IO.File.Exists(tempPathDot), "File should be invisible to System.IO.");

         using (StreamWriter sw = File.AppendText(tempPathDot, PathFormat.FullPath))
            sw.WriteLine(TextHelloWorld);

         string lineAlphaFs;
         using (StreamReader sr = File.OpenText(tempPathDot, PathFormat.FullPath))
            lineAlphaFs = sr.ReadToEnd();

         File.Delete(tempPathDot, true, PathFormat.FullPath); // Delete file without path normalization.
         Assert.IsFalse(File.Exists(tempPathDot, PathFormat.FullPath), "File should not exist.");

         #endregion // AlphaFS

         Assert.AreEqual(lineSysIo, lineAlphaFs);

         #endregion // TrailingDot

         #region TrailingSpace

         #region System.IO

         // tempPathSpace contains a trailing space but gets stripped on path normalization.
         // System.IO handles the file without the trailing space. Therefore, the file exists.
         // AlphaFS has the same behaviour as .NET for default methods.

         using (FileStream fs = System.IO.File.Create(tempPathSpace)) { fs.WriteByte(1); }
         Assert.IsTrue(System.IO.File.Exists(tempPathSpace), "File should exist.");
         Assert.IsTrue(File.Exists(tempPathSpace), "File should be visible to AlphaFS.");
         Assert.IsFalse(File.Exists(tempPathSpace, PathFormat.FullPath), "File should be invisible to AlphaFS.");

         using (StreamWriter sw = System.IO.File.AppendText(tempPathSpace))
            sw.WriteLine(TextHelloWorld);

         using (StreamReader sr = System.IO.File.OpenText(tempPathSpace))
            lineSysIo = sr.ReadToEnd();

         System.IO.File.Delete(tempPathSpace);
         Assert.IsFalse(System.IO.File.Exists(tempPathSpace), "File should not exist.");

         #endregion // System.IO

         #region AlphaFS

         using (FileStream fs = File.Create(tempPathSpace, PathFormat.FullPath)) { fs.WriteByte(1); } // Create file without path normalization.
         Assert.IsTrue(File.Exists(tempPathSpace, PathFormat.FullPath), "File should exist and visible to AlphaFS.");
         Assert.IsFalse(System.IO.File.Exists(tempPathSpace), "File should be invisible to System.IO.");

         using (StreamWriter sw = File.AppendText(tempPathSpace, PathFormat.FullPath))
            sw.WriteLine(TextHelloWorld);

         using (StreamReader sr = File.OpenText(tempPathSpace, PathFormat.FullPath))
            lineAlphaFs = sr.ReadToEnd();

         File.Delete(tempPathSpace, true, PathFormat.FullPath); // Delete file without path normalization.
         Assert.IsFalse(File.Exists(tempPathSpace, PathFormat.FullPath), "File should not exist.");

         #endregion // AlphaFS

         Assert.AreEqual(lineSysIo, lineAlphaFs);

         #endregion // TrailingSpace

         Console.WriteLine("\tClass File(){0}", Reporter());

         #endregion // File() Class

         #region FileInfo() Class

         StopWatcher(true);

         #region TrailingDot

         #region System.IO

         // tempPathDot contains a trailing dot but gets stripped on path normalization.
         // System.IO handles the file without the trailing dot. Therefore, the file exists.
         // AlphaFS has the same behaviour as .NET for default methods.

         System.IO.FileInfo sysIoFi = new System.IO.FileInfo(tempPathDot);
         Assert.IsTrue(sysIoFi.Name.EndsWith(characterDot), "Path should have a trailing dot.");

         using (FileStream fs = sysIoFi.Create())
         {
            fs.WriteByte(100);

            Assert.IsTrue(sysIoFi.Exists, "File should exist.");
            Assert.IsTrue(File.Exists(tempPathDot), "File should be visible to AlphaFS.");
            Assert.IsFalse(File.Exists(tempPathDot, PathFormat.FullPath), "File should be invisible to AlphaFS.");
         }

         using (StreamWriter sw = sysIoFi.AppendText())
            sw.WriteLine(TextHelloWorld);

         using (StreamReader sr = System.IO.File.OpenText(tempPathDot))
            lineSysIo = sr.ReadToEnd();

         sysIoFi.Delete();
         Assert.IsFalse(System.IO.File.Exists(tempPathDot), "File should not exist.");

         #endregion // System.IO

         #region AlphaFS

         FileInfo alphaFsFi = new FileInfo(tempPathDot, PathFormat.FullPath);
         Assert.IsTrue(alphaFsFi.Name.EndsWith(characterDot), "Path should have a trailing dot.");

         using (FileStream fs = alphaFsFi.Create())
         {
            fs.WriteByte(100);

            Assert.IsTrue(alphaFsFi.Exists, "File should exist.");
            Assert.IsTrue(File.Exists(tempPathDot, PathFormat.FullPath), "File should be visible to AlphaFS.");
            Assert.IsFalse(File.Exists(tempPathDot), "File should be invisible to AlphaFS.");
         }

         using (StreamWriter sw = alphaFsFi.AppendText())
            sw.WriteLine(TextHelloWorld);

         using (StreamReader sr = File.OpenText(tempPathDot, PathFormat.FullPath))
            lineAlphaFs = sr.ReadToEnd();

         alphaFsFi.Delete();
         alphaFsFi.Refresh(); // Must Refresh() to get actual state.
         Assert.IsFalse(File.Exists(tempPathDot, PathFormat.FullPath), "File should not exist.");

         #endregion // AlphaFS

         Assert.AreEqual(lineSysIo, lineAlphaFs);

         #endregion // TrailingDot

         #region TrailingSpace

         #region System.IO

         // tempPathSpace contains a trailing space but gets stripped on path normalization.
         // System.IO handles the file without the trailing space. Therefore, the file exists.
         // AlphaFS has the same behaviour as .NET for default methods.

         sysIoFi = new System.IO.FileInfo(tempPathSpace);
         Assert.IsTrue(sysIoFi.Name.EndsWith(characterSpace), "Path should have a trailing space.");

         using (FileStream fs = sysIoFi.Create())
         {
            fs.WriteByte(100);

            Assert.IsTrue(sysIoFi.Exists, "File should exist.");
            Assert.IsTrue(File.Exists(tempPathSpace), "File should be visible to AlphaFS.");
            Assert.IsFalse(File.Exists(tempPathSpace, PathFormat.FullPath), "File should be invisible to AlphaFS.");
         }

         using (StreamWriter sw = sysIoFi.AppendText())
            sw.WriteLine(TextHelloWorld);

         using (StreamReader sr = System.IO.File.OpenText(tempPathSpace))
            lineSysIo = sr.ReadToEnd();

         sysIoFi.Delete();
         Assert.IsFalse(System.IO.File.Exists(tempPathSpace), "File should not exist.");

         #endregion // System.IO

         #region AlphaFS

         alphaFsFi = new FileInfo(tempPathSpace, PathFormat.FullPath);
         Assert.IsTrue(alphaFsFi.Name.EndsWith(characterSpace), "Path should have a trailing space.");

         using (FileStream fs = alphaFsFi.Create())
         {
            fs.WriteByte(100);

            Assert.IsTrue(alphaFsFi.Exists, "File should exist.");
            Assert.IsTrue(File.Exists(tempPathSpace, PathFormat.FullPath), "File should be visible to AlphaFS.");
            Assert.IsFalse(File.Exists(tempPathSpace), "File should be invisible to AlphaFS.");
         }

         using (StreamWriter sw = alphaFsFi.AppendText())
            sw.WriteLine(TextHelloWorld);

         using (StreamReader sr = File.OpenText(tempPathSpace, PathFormat.FullPath))
            lineAlphaFs = sr.ReadToEnd();

         alphaFsFi.Delete();
         alphaFsFi.Refresh(); // Must Refresh() to get actual state.
         Assert.IsFalse(File.Exists(tempPathSpace, PathFormat.FullPath), "File should not exist.");

         #endregion // AlphaFS

         Assert.AreEqual(lineSysIo, lineAlphaFs);

         #endregion // TrailingSpace

         Console.WriteLine("\tClass FileInfo(){0}", Reporter());

         #endregion // FileInfo() Class

         Console.WriteLine();
      }