Thinktecture.Tools.Web.Services.CodeGeneration.CodeWriter.EnsureDirectoryExists C# (CSharp) Method

EnsureDirectoryExists() private static method

This is a helper method to ensure that a given directory exists in the file system.
If the specified directory does not exist in the file system this method creates it before returning.
private static EnsureDirectoryExists ( string directory ) : void
directory string
return void
        private static void EnsureDirectoryExists(string directory)
        {
            // Some assertions to make debugging easier.
            Debug.Assert(!string.IsNullOrEmpty(directory), "directory parameter could not be null or an empty string.");

            try
            {
                // Can't we see the directory in the file system?
                if (!Directory.Exists(directory))
                {
                    // Create it.
                    Directory.CreateDirectory(directory);
                }
            }
            catch (IOException e)
            {
                throw new CodeWriterException(
                    string.Format("An error occurred while trying verify the output directory: {0}", e.Message), e);
            }
        }