public static void TestReadWriteAccessToShare(ILogger logger, UncPath uncPath)
 {
     try
     {
         logger.LogInfo(string.Format("Trying to test unc {0}.", uncPath));
         FileCheckHelper.WriteTestFileToDirectory(logger, uncPath);
         FileCheckHelper.ReadTestFileFromDirectoryAndCompare(logger, uncPath);
         FileCheckHelper.DeleteTestFileFromDirectory(logger, uncPath);
         logger.LogInfo(string.Format("Test unc {0} succeeded.", uncPath));
     }
     catch (Exception ex)
     {
         throw new DirectoryException(string.Format("Test write and write fails on unc {0}.", uncPath), ex);
     }
 }
        public static void ReadTestFileFromDirectoryAndCompare(ILogger logger, UncPath uncPath)
        {
            logger.LogDebug(string.Format("Reading file to Uri {0} comprised of {1} and {2}.", uncPath.BuildUncPath() + DIRECTORYTESTFILE, uncPath.BuildUncPath(), DIRECTORYTESTFILE));
            bool match = false;

            string[] readLines = File.ReadAllLines(uncPath.BuildUncPath() + DIRECTORYTESTFILE);
            if (readLines.Length == 3)
            {
                if (readLines[0].Equals(lines[0]) && readLines[1].Equals(lines[1]) && readLines[2].Equals(lines[2]))
                {
                    logger.LogDebug("Lines read from testfile correct.");
                    match = true;
                }
            }

            if (!match)
            {
                throw new FileCheckException(string.Format("Filecheck failed for {0}", uncPath.BuildUncPath()));
            }
        }
 public static void DeleteTestFileFromDirectory(ILogger logger, UncPath uncPath)
 {
     logger.LogDebug(string.Format("Reading file to Uri {0} comprised of {1} and {2}.", uncPath.BuildUncPath() + DIRECTORYTESTFILE, uncPath.BuildUncPath(), DIRECTORYTESTFILE));
     File.Delete(uncPath.BuildUncPath() + DIRECTORYTESTFILE);
     logger.LogDebug(string.Format("Test file {0} deleted.", uncPath.BuildUncPath() + DIRECTORYTESTFILE));
 }
 public static void WriteTestFileToDirectory(ILogger logger, UncPath uncPath)
 {
     logger.LogDebug(string.Format("Writing file to Uri {0} comprised of {1} and {2}.", uncPath.BuildUncPath() + DIRECTORYTESTFILE, uncPath.BuildUncPath(), DIRECTORYTESTFILE));
     File.WriteAllLines(uncPath.BuildUncPath() + DIRECTORYTESTFILE, lines);
     logger.LogDebug(string.Format("Test file written {0}.", uncPath.BuildUncPath() + DIRECTORYTESTFILE));
 }