/// <summary>
        /// Using the supplied Startup class attempts to correctly locate our project root.  We traverse the ancestor tree in case
        /// the integration tests derives from the application's startup class
        /// </summary>
        /// <param name="projectRelativePath">The project relative path.</param>
        /// <param name="startupType">Type of the startup.</param>
        /// <returns></returns>
        private static string GetProjectPathFromAncestors(string projectRelativePath, Type startupType)
        {
            //get all ansectors type from current type
            Type type = startupType;
            DirectoryNotFoundException lastException = null;

            while (type != null)
            {
                try
                {
                    var path = GetProjectPath(projectRelativePath, type.Assembly);
                    return(path);
                }
                catch (DirectoryNotFoundException d)
                {
                    lastException = d;
                }
                type = type.BaseType;
            }
            if (lastException != null)
            {
                throw lastException;
            }
            return(null);
        }
Beispiel #2
0
        public void SaveFile(Action <Exception> callback, IEnumerable <string> data, string nameFile)
        {
            Exception error = null;

            if (Directory.Exists(Path.GetDirectoryName(Path.GetFullPath(nameFile))))
            {
                try
                {
                    using (StreamWriter sw = new StreamWriter(File.OpenWrite(nameFile), Encoding.Default))
                    {
                        foreach (var item in data)
                        {
                            sw.WriteLine(item);
                        }
                    }
                }
                catch (Exception ex)
                {
                    error = ex;
                }
            }
            else
            {
                error = new DirectoryNotFoundException();
            }

            callback(error);
        }
Beispiel #3
0
        void IPscxErrorHandler.WriteDirectoryNotFoundError(string path)
        {
            string    msg = string.Format(Resources.Errors.DirectoryNotFound, path);
            Exception ex  = new DirectoryNotFoundException(msg);

            ErrorHandler.WriteFileError(path, ex);
        }
Beispiel #4
0
 private void DirectoryeNotFoundMessage(DirectoryNotFoundException e)
 {
     Console.ForegroundColor = ConsoleColor.Red;
     Console.WriteLine("Директория не найдена");
     Console.WriteLine(e.Message);
     Console.ResetColor();
 }
Beispiel #5
0
        /// <summary>
        /// Метод для сохранения данных в файл
        /// </summary>
        /// <param name="callback">Функция обратного вызова, с параметром ошибка</param>
        /// <param name="data">Множество данных для записи</param>
        /// <param name="file">Файл куда записывать</param>
        public void SaveData(Action <Exception> callback, IEnumerable <string> data, string file)
        {
            Exception error = null;

            try
            {
                if (Directory.Exists(Path.GetDirectoryName(file)))
                {
                    // utf-8 с Bom не читается системой, приходится так
                    Encoding utf = new UTF8Encoding(false);
                    using (StreamWriter sw = new StreamWriter(File.Create(file), utf))
                    {
                        foreach (var item in data)
                        {
                            sw.WriteLine(item);
                        }
                    }
                }
                else
                {
                    error = new DirectoryNotFoundException();
                }
            }
            catch (Exception ex)
            {
                error = ex;
            }

            callback(error);
        }
Beispiel #6
0
        public void Send_SpecifiedPickupDirectory_PickupDirectoryLocation_DirectoryNotFound()
        {
            Directory.Delete(tempFolder);

            smtp.DeliveryMethod          = SmtpDeliveryMethod.SpecifiedPickupDirectory;
            smtp.PickupDirectoryLocation = tempFolder;
            try {
                smtp.Send("*****@*****.**", "*****@*****.**",
                          "introduction", "hello");
                Assert.Fail("#1");
            } catch (SmtpException ex) {
                // Failure sending email
                Assert.AreEqual(typeof(SmtpException), ex.GetType(), "#2");
                Assert.IsNotNull(ex.InnerException, "#3");
                Assert.AreEqual(typeof(DirectoryNotFoundException), ex.InnerException.GetType(), "#4");
                Assert.IsNotNull(ex.Message, "#5");
                Assert.AreEqual(SmtpStatusCode.GeneralFailure, ex.StatusCode, "#6");

                // Could not find a part of the path '...'
                DirectoryNotFoundException inner = (DirectoryNotFoundException)ex.InnerException;
                Assert.IsNull(inner.InnerException, "#7");
                Assert.IsNotNull(inner.Message, "#8");
                Assert.IsTrue(inner.Message.IndexOf(tempFolder) != -1, "#9");
            }
        }
 /// <summary>
 ///
 /// </summary>
 /// <param name="action"></param>
 /// <returns>True if directory existed. If it was created - returns false</returns>
 public static bool CreateDirectoryIfItDoesntExistForFile(string fileName, Action action)
 {
     try
     {
         action();
         return(true);
     }
     catch (DirectoryNotFoundException)
     {
         if (CreateDirectoryForFile(fileName, checkExistense: false))
         {
             action();
         }
     }
     catch (Exception ex)
     {
         Exception innerException = ex.InnerException;
         while (innerException != null)
         {
             DirectoryNotFoundException directoryNotFoundException = innerException as DirectoryNotFoundException;
             if (directoryNotFoundException != null)
             {
                 if (CreateDirectoryForFile(fileName))
                 {
                     action();
                 }
                 return(false);
             }
             innerException = innerException.InnerException;
         }
         throw ex;
     }
     return(false);
 }
        public static void Ctor_String()
        {
            string message   = "That page was missing from the directory.";
            var    exception = new DirectoryNotFoundException(message);

            ExceptionUtility.ValidateExceptionProperties(exception, hResult: HResults.COR_E_DIRECTORYNOTFOUND, message: message);
        }
        private bool ValidateJobDefinition(ScheduledJobDefinition definition)
        {
            Exception exception = null;

            try
            {
                definition.SyncWithWTS();
            }
            catch (DirectoryNotFoundException directoryNotFoundException1)
            {
                DirectoryNotFoundException directoryNotFoundException = directoryNotFoundException1;
                exception = directoryNotFoundException;
            }
            catch (FileNotFoundException fileNotFoundException1)
            {
                FileNotFoundException fileNotFoundException = fileNotFoundException1;
                exception = fileNotFoundException;
            }
            catch (ArgumentNullException argumentNullException1)
            {
                ArgumentNullException argumentNullException = argumentNullException1;
                exception = argumentNullException;
            }
            if (exception != null)
            {
                this.WriteErrorLoadingDefinition(definition.Name, exception);
            }
            return(exception == null);
        }
Beispiel #10
0
        static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
        {
            if (e.Exception is DirectoryNotFoundException)
            {
                DirectoryNotFoundException theException = (DirectoryNotFoundException)e.Exception;
                BLIO.WriteError(theException, "Folder not found.");
                ShowError(e.Exception, e.Exception.GetType().ToString(), theException.Message);
            }

            if (e.Exception is UnauthorizedAccessException)
            {
                UnauthorizedAccessException theException = (UnauthorizedAccessException)e.Exception;
                BLIO.WriteError(e.Exception, "Unauthorized!");
                ShowError(e.Exception, "Unauthorized!", "not authorized for this action.\r\nThis can be resolved by running in administrator-mode.");
            }

            //Here we just filter out some type of exceptions and give different messages, at the bottom is the super Exception, which can be anything.
            else if (e.Exception is FileNotFoundException)
            {
                FileNotFoundException theException = (FileNotFoundException)e.Exception; //needs in instance to call .FileName
                BLIO.WriteError(theException, "converteruld not find the file located at \"" + theException.FileName);
                ShowError(e.Exception, "File not found.", "Could not find the file located at \"" + theException.FileName + "\"\r\nHave you moved,renamed or deleted the file?");
            }

            else if (e.Exception is System.Data.Entity.Core.EntityException)
            {
                BLIO.WriteError(e.Exception, "System.Data.Entity.Core.EntityException");
                ShowError(e.Exception, "System.Data.Entity.Core.EntityException", "There was a problem executing SQL!");
            }

            else if (e.Exception is ArgumentNullException)
            {
                BLIO.WriteError(e.Exception, "Null argument");
                ShowError(e.Exception, "Null argument", "Null argument exception! Whoops! this is not on your end!");
            }

            else if (e.Exception is NullReferenceException)
            {
                BLIO.WriteError(e.Exception, "Null reference");
                ShowError(e.Exception, "Null reference", "Null reference exception! Whoops! this is not on your end!");
            }

            else if (e.Exception is SQLiteException)
            {
                BLIO.WriteError(e.Exception, "SQLite Database exception");
                ShowError(e.Exception, "SQLite Database exception", "encountered a database error!\r\nThis might or might not be on your end. It can be on your end if you modified the database file");
            }

            else if (e.Exception is PathTooLongException)
            {
                BLIO.WriteError(e.Exception, "The path to the file is too long.");
                ShowError(e.Exception, "File Path too long.", "The path to the file is too long!.");
            }


            else if (e.Exception is Exception)
            {
                BLIO.WriteError(e.Exception, "Unknown exception in main.");
            }
        }
        public IEnumerable <string> FilterFilePathsFromFolder(
            string folderPath,
            FileExtensions fileExtensionsToCollect,
            bool isIncludingSubdirectories)
        {
            if (!Directory.Exists(folderPath))
            {
                var folderNotFoundException =
                    new DirectoryNotFoundException("The following directory couldn't be found: " + folderPath);
                folderNotFoundException.Data.Add("folder", folderPath);
                throw folderNotFoundException;
            }

            SearchOption currentDirectorySearchOption =
                isIncludingSubdirectories ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly;

            if (fileExtensionsToCollect.HasFlag(FileExtensions.Any))
            {
                return(CollectAllFilePathsIgnoreFileExtension(folderPath, currentDirectorySearchOption));
            }

            return(CollectFilePathsFromFolderByFileExtension(
                       folderPath,
                       fileExtensionsToCollect,
                       currentDirectorySearchOption));
        }
Beispiel #12
0
        /// <summary>
        /// Displays an error message when DirectoryNotFoundException is thrown.
        /// </summary>
        /// <param name="ex">The exception</param>
        private static void ShowException(DirectoryNotFoundException ex)
        {
            PrepareToShow();
            string errorMessage = Util.CombineMessageParts(SharedStrings.DIRECTORY_NOT_FOUND, ex.Message);

            ShowError(errorMessage, false);
        }
    public bool PosTest1()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest1: Create a new DirectoryNotFoundException instance.");

        try
        {
            string expectString = "This is an error";
            DirectoryNotFoundException myException = new DirectoryNotFoundException(expectString);
            if (myException.Message != expectString)
            {
                TestLibrary.TestFramework.LogError("001.1", "the DirectoryNotFoundException ctor error occurred.the message should be " + expectString);
                retVal = false;
            }

        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("001.2", "Unexpected exception: " + e);
            retVal = false;
        }

        return retVal;
    }
    public bool PosTest3()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest3: Create a new DirectoryNotFoundException instance,string is null.");

        try
        {
            string expectString = null;
            DirectoryNotFoundException myException = new DirectoryNotFoundException(expectString);
            if (myException == null)
            {
                TestLibrary.TestFramework.LogError("003.1", "the DirectoryNotFoundException ctor error occurred. the message should be null");
                retVal = false;
            }

        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("003.2", "Unexpected exception: " + e);
            retVal = false;
        }

        return retVal;
    }
Beispiel #15
0
        // 何かやって例外出た時に、調べられる限り原因を調べる
        public static Exception InspectIoError(string path, string toPath, Exception originalException)
        {
            Exception ret = originalException;

            try
            {
                var info = new FileInfo(path);
                if (!info.Exists)                 // ファイルなくなってる
                {
                    ret = new FileNotFoundException("File not found: " + path);
                }
                else if (toPath != null)
                {
                    var toInfo = new FileInfo(toPath);
                    if (toInfo.Exists)
                    {
                        ret = new IOException("destination path already exists. " + toPath);
                    }
                    else if (!toInfo.Directory.Exists)
                    {
                        ret = new DirectoryNotFoundException("destination directory not found: " + toPath);
                    }
                }
            }
            catch (Exception e)
            {
                ret = e;
            }
            return(ret);
        }
        public static void HandleException(Window window, DirectoryNotFoundException ex)
        {
            try
            {
                string message = string.Format(Properties.Resources.MessageDirectoryNotFoundException);

                TaskDialog dialog = new TaskDialog();

                dialog.InstructionText = message;
                //dialog.Text
                dialog.Icon            = TaskDialogStandardIcon.Error;
                dialog.StandardButtons = TaskDialogStandardButtons.Ok;

                dialog.DetailsExpandedText = ex.Message;

                dialog.Caption = App.Current.ApplicationTitle;
                if (window != null)
                {
                    dialog.OwnerWindowHandle = new WindowInteropHelper(window).Handle;
                }

                dialog.Show();
            }
            catch (PlatformNotSupportedException)
            {
                MessageBox.Show(ex.Message);
            }
        }
        public void ShouldIgnoreException_IgnoreErrorMessages(bool hasIgnoreError)
        {
            var ignoreErrorMessages = new Dictionary <string, IEnumerable <string> >
            {
                { "System.IO.DirectoryNotFoundException", new List <string>()
                  {
                      "error message 1", "error message 2"
                  } }
            };

            if (hasIgnoreError)
            {
                SetupConfiguration(null, null, ignoreErrorMessages, null, false, null, null, null, errorCollectorEnabled: true);
            }

            var ignoreException1 = new DirectoryNotFoundException("this is error message 1 ");
            var ignoreException2 = new DirectoryNotFoundException("this is error message 2 ");


            if (hasIgnoreError)
            {
                Assert.True(_errorService.ShouldIgnoreException(ignoreException1));
                Assert.True(_errorService.ShouldIgnoreException(ignoreException2));
            }
            else
            {
                Assert.False(_errorService.ShouldIgnoreException(ignoreException1));
                Assert.False(_errorService.ShouldIgnoreException(ignoreException2));
            }
        }
Beispiel #18
0
            public static DirectoryNotFoundException /*!*/ Create(RubyClass /*!*/ self, [DefaultProtocol, DefaultParameterValue(null)] MutableString message)
            {
                DirectoryNotFoundException result = new DirectoryNotFoundException(RubyExceptions.MakeMessage(ref message, "Not a directory"));

                RubyExceptionData.InitializeException(result, message);
                return(result);
            }
        public static void From_HR(int hr)
        {
            DirectoryNotFoundException exception = Assert.IsAssignableFrom <DirectoryNotFoundException>(Marshal.GetExceptionForHR(hr));

            // Don't validate the message.  Currently .NET Native does not produce HR-specific messages
            ExceptionUtility.ValidateExceptionProperties(exception, hResult: hr, validateMessage: false);
        }
Beispiel #20
0
        public void GetFriendlyName_NonGeneric_ShouldEqualTypeName()
        {
            var item   = new DirectoryNotFoundException();
            var result = item.GetType().GetFriendlyName();

            result.ShouldBe("DirectoryNotFoundException");
        }
        /// <summary>
        /// Serialise the CDA document to an XML file
        /// </summary>
        /// <param name="fileLocation">filename of the XML file to be created</param>
        public void CreateXML(string fileLocation)
        {
            FileInfo tagetInfo = new FileInfo(fileLocation);

            if (tagetInfo.Directory.Exists)
            {
                XmlWriterSettings settings = new XmlWriterSettings();
                settings.Indent      = true;
                settings.IndentChars = ("    ");

                using (XmlWriter writer = XmlWriter.Create(fileLocation, settings))
                {
                    writeXmlCommentBlock(writer);

                    writer.WriteStartElement("ClinicalDocument", "urn:hl7-org:v3");
                    writeXml(writer);
                    writer.WriteEndElement();
                    writer.Flush();
                }
            }
            else
            {
                ApplicationException       exInner = new ApplicationException(tagetInfo.DirectoryName);
                DirectoryNotFoundException ex      = new DirectoryNotFoundException("Target Directory does not exist", exInner);
                throw ex;
            }
        }
    public static void DirectoryNotFoundException_ctor_string()
    {
        string message = "That page was missing from the directory.";
        DirectoryNotFoundException dnfe = new DirectoryNotFoundException(message);

        Utility.ValidateExceptionProperties(dnfe, hResult: HResults.COR_E_DIRECTORYNOTFOUND, message: message);
    }
Beispiel #23
0
        private Task <FileInfo> FindFile(DirectoryInfo directory, string name)
        {
            if (!directory.Exists)
            {
                Exception directoryException = new DirectoryNotFoundException("The journal directory does not exist");
                directoryException.Data.Add("Directory", directory.FullName);
                directoryException.Data.Add("File", name);
                throw directoryException;
            }

            var files = directory.GetFiles(name);

            if (files.Length > 0)
            {
                return(Task.FromResult(files.First()));
            }

            if (name == "Status.json")
            {
                var path          = Path.Combine(directory.FullName, name);
                var fileException = new FileNotFoundException("The file does not exist", path);
                fileException.Data.Add("Directory", directory.FullName);
                fileException.Data.Add("File", name);
                throw fileException;
            }

            return(Task.FromResult <FileInfo>(null));
        }
 public static void DirectoryNotFoundException_ctor_string_exception()
 {
     string message = "That page was missing from the directory.";
     Exception innerException = new Exception("Inner exception");
     DirectoryNotFoundException dnfe = new DirectoryNotFoundException(message, innerException);
     Utility.ValidateExceptionProperties(dnfe, hResult: HResults.COR_E_DIRECTORYNOTFOUND, innerException: innerException, message: message);
 }
        public void FromException_MarkErrorDataAsExpected_ExpectedErrorMessages(bool hasExpectedError)
        {
            var expectedMessages = new Dictionary <string, IEnumerable <string> >
            {
                { "System.IO.DirectoryNotFoundException", new List <string>()
                  {
                      "error message 1", "error message 2"
                  } }
            };

            if (hasExpectedError)
            {
                SetupConfiguration(null, null, null, null, false, null, expectedMessages, null, errorCollectorEnabled: true);
            }

            var expectedException1 = new DirectoryNotFoundException("this is error message 1 ");
            var expectedException2 = new DirectoryNotFoundException("this is error message 2 ");

            var errorData1 = _errorService.FromException(expectedException1);
            var errorData2 = _errorService.FromException(expectedException2);

            if (hasExpectedError)
            {
                Assert.IsTrue(errorData1.IsExpected);
                Assert.IsTrue(errorData2.IsExpected);
            }
            else
            {
                Assert.IsFalse(errorData1.IsExpected);
                Assert.IsFalse(errorData2.IsExpected);
            }
        }
        public Stream DownloadFileContentAsStream(string fileShareName, string fileName = "")
        {
            CloudFileClient fileClient = new CloudFileClient(fileURI, creds);
            // Create a CloudFileClient object for credentialed access to Azure Files.
            Stream s = null;

            // Get a reference to the file share we created previously.
            CloudFileShare share = fileClient.GetShareReference(fileShareName);

            // Ensure that the share exists.
            if (share.Exists())
            {
                try
                {
                    // Get a reference to the root directory for the share.
                    CloudFileDirectory rootDir   = share.GetRootDirectoryReference();
                    CloudFile          cloudFile = rootDir.GetFileReference(fileName);
                    cloudFile.DownloadToStream(s);
                    return(s);
                }
                catch (Exception e)
                {
                    throw new StorageAccountException("Error while attempting to get contents", e);
                }
            }
            else
            {
                DirectoryNotFoundException e = new DirectoryNotFoundException(string.Format("The file share '{0}' does not exist.", fileShareName));
                throw new StorageAccountException("Error while attempting to get content", e);
            }
        }
        public static void Ctor_String_Exception()
        {
            string message        = "That page was missing from the directory.";
            var    innerException = new Exception("Inner exception");
            var    exception      = new DirectoryNotFoundException(message, innerException);

            ExceptionHelpers.ValidateExceptionProperties(exception, hResult: HResults.COR_E_DIRECTORYNOTFOUND, innerException: innerException, message: message);
        }
Beispiel #28
0
        private static string GetDirectory(this DirectoryNotFoundException exception)
        {
            var message  = exception.Message;
            var beginPos = message.IndexOf('"');
            var endPos   = message.IndexOf('"', beginPos + 1);

            return(Path.GetDirectoryName(message.Substring(beginPos + 1, endPos - beginPos - 1)));
        }
        private static InvalidRepositoryConfigurationException CreateDirectoryNotFoundException(string directory)
        {
            var innerException =
                new DirectoryNotFoundException(
                    $"The specified repository in the configuration file was not found: {directory}");

            return(CreateInvalidRepositoryConfigurationException(innerException));
        }
Beispiel #30
0
 public ExceptionsCollection()
 {
     ex[0] = new DivideByZeroException();
     ex[1] = new DirectoryNotFoundException();
     ex[2] = new ArgumentException();
     ex[3] = new MyException("Моё исключение.");
     ex[4] = new ArgumentNullException();
 }
        public void DownloadFileToLocalPath(string fileShareName, string localPath, FileMode mode, string fileName = "")
        {
            CloudFileClient fileClient = new CloudFileClient(fileURI, creds);
            // Create a CloudFileClient object for credentialed access to Azure Files.


            // Get a reference to the file share we created previously.
            CloudFileShare share = fileClient.GetShareReference(fileShareName);

            // Ensure that the share exists.
            if (share.Exists())
            {
                try
                {
                    // Get a reference to the root directory for the share.
                    CloudFileDirectory rootDir   = share.GetRootDirectoryReference();
                    CloudFile          cloudFile = rootDir.GetFileReference(fileName);
                    switch (mode)
                    {
                    case FileMode.Append:
                        cloudFile.DownloadToFile(localPath, FileMode.Append);
                        break;

                    case FileMode.Create:
                        cloudFile.DownloadToFile(localPath, FileMode.Create);
                        break;

                    case FileMode.CreateNew:
                        cloudFile.DownloadToFile(localPath, FileMode.CreateNew);
                        break;

                    case FileMode.Open:
                        cloudFile.DownloadToFile(localPath, FileMode.Open);
                        break;

                    case FileMode.OpenOrCreate:
                        cloudFile.DownloadToFile(localPath, FileMode.OpenOrCreate);
                        break;

                    case FileMode.Truncate:
                        cloudFile.DownloadToFile(localPath, FileMode.Truncate);
                        break;

                    default:
                        break;
                    }
                }
                catch (Exception e)
                {
                    throw new StorageAccountException("Error while attempting to get contents", e);
                }
            }
            else
            {
                DirectoryNotFoundException e = new DirectoryNotFoundException(string.Format("The file share '{0}' does not exist.", fileShareName));
                throw new StorageAccountException("Error while attempting to get content", e);
            }
        }
Beispiel #32
0
        internal static NativeMethods.WIN32_FIND_DATA GetExtendedNonRootDirectoryInfo(string path, out Exception exception)
        {
            exception = null;
            NativeMethods.WIN32_FIND_DATA win32_FIND_DATA = default(NativeMethods.WIN32_FIND_DATA);
            DirectoryInfo di = null;

            exception = MountPointUtil.HandleIOExceptions(delegate
            {
                di = new DirectoryInfo(path);
            });
            if (exception != null)
            {
                return(win32_FIND_DATA);
            }
            if (!di.Exists)
            {
                exception = new DirectoryNotFoundException();
                return(win32_FIND_DATA);
            }
            if (di.Parent == null)
            {
                DiagCore.RetailAssert(false, "An invalid root path was passed in: {0}", new object[]
                {
                    path
                });
                exception = new IOException(string.Format("An invalid root path was passed in: {0}", path));
                return(win32_FIND_DATA);
            }
            NativeMethods.WIN32_FIND_DATA result;
            using (DirectoryEnumerator dirEnum = new DirectoryEnumerator(di.Parent, false, false))
            {
                bool foundNext = false;
                NativeMethods.WIN32_FIND_DATA tempFindData = default(NativeMethods.WIN32_FIND_DATA);
                string dirName;
                exception = MountPointUtil.HandleIOExceptions(delegate
                {
                    foundNext = dirEnum.GetNextDirectoryExtendedInfo(di.Name, out dirName, out tempFindData);
                });
                if (exception != null)
                {
                    result = win32_FIND_DATA;
                }
                else if (!foundNext)
                {
                    exception = new DirectoryNotFoundException();
                    result    = win32_FIND_DATA;
                }
                else
                {
                    exception = null;
                    result    = tempFindData;
                }
            }
            return(result);
        }
        private List <FileInfo> GetFilesFromDirectory(DirectoryInfo directory, bool includeSubDirectories)
        {
            List <FileInfo> fileInfos;

            FileInfo[]      filesArray = directory.GetFiles("*.*");
            List <FileInfo> files      = new List <FileInfo>();

            FileInfo[] fileInfoArray = filesArray;
            for (int i = 0; i < (int)fileInfoArray.Length; i++)
            {
                FileInfo f = fileInfoArray[i];
                try
                {
                    string fullName = f.FullName;
                    files.Add(f);
                }
                catch (PathTooLongException pathTooLongException)
                {
                    string[] str = new string[] { "Directory: ", directory.ToString(), " File: ", f.ToString(), " Excluded from selection as path too long " };
                    Log.WriteLog(string.Concat(str), "Error", this.GetType().Name, this.AppConfig);
                }
            }
            try
            {
                if (includeSubDirectories)
                {
                    DirectoryInfo[] directories = directory.GetDirectories();
                    for (int j = 0; j < (int)directories.Length; j++)
                    {
                        DirectoryInfo aDirectory = directories[j];
                        try
                        {
                            files.AddRange(this.GetFilesFromDirectory(aDirectory, true));
                        }
                        catch
                        {
                        }
                    }
                }
                fileInfos = files;
            }
            catch (UnauthorizedAccessException unauthorizedAccessException)
            {
                UnauthorizedAccessException e = unauthorizedAccessException;
                Log.WriteLog(e.Message, "Error", this.GetType().Name, this.AppConfig);
                throw e;
            }
            catch (DirectoryNotFoundException directoryNotFoundException)
            {
                DirectoryNotFoundException e = directoryNotFoundException;
                Log.WriteLog(e.Message, "Error", this.GetType().Name, this.AppConfig);
                throw e;
            }
            return(fileInfos);
        }
    public bool PosTest1()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest1: Create a new DirectoryNotFoundException instance.");

        try
        {
            DirectoryNotFoundException myException = new DirectoryNotFoundException();
            if (myException==null)
            {
                TestLibrary.TestFramework.LogError("001.1", "the DirectoryNotFoundException ctor error occurred. ");
                retVal = false;
            }

        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("001.2", "Unexpected exception: " + e);
            retVal = false;
        }

        return retVal;
    }
 public static void DirectoryNotFoundException_ctor()
 {
     DirectoryNotFoundException dnfe = new DirectoryNotFoundException();
     Utility.ValidateExceptionProperties(dnfe, hResult: HResults.COR_E_DIRECTORYNOTFOUND, validateMessage: false);
 }