CKFinder.Connector.Util.CreateDirectory C# (CSharp) Method

CreateDirectory() public static method

This method should provide safe substitude for Directory.CreateDirectory().

This method creates all the directory structure if needed.

The System.IO.Directory.CreateDirectory() method has a bug that gives an error when trying to create a directory and the user has no rights defined in one of its parent directories. The CreateDirectory() should be a good replacement to solve this problem.

public static CreateDirectory ( string path ) : Achilles.Acme.Storage.IO.DirectoryInfo
path string The directory path to be created.
return Achilles.Acme.Storage.IO.DirectoryInfo
        public static Achilles.Acme.Storage.IO.DirectoryInfo CreateDirectory( string path )
        {
            // Create the directory info object for that dir (normalized to its absolute representation).
            Achilles.Acme.Storage.IO.DirectoryInfo oDir = new Achilles.Acme.Storage.IO.DirectoryInfo( Path.GetFullPath( path ) );

            try
            {
                // Try to create the directory by using standard .Net features. (#415)
                if ( !oDir.Exists )
                    oDir.Create();

                return oDir;
            }
            catch
            {
                // TJT: Review this code

                CreateDirectoryUsingDll( oDir );

                return new Achilles.Acme.Storage.IO.DirectoryInfo( path );
            }
        }