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

CreateDirectoryUsingDll() private static method

private static CreateDirectoryUsingDll ( Achilles dir ) : void
dir Achilles
return void
        private static void CreateDirectoryUsingDll( Achilles.Acme.Storage.IO.DirectoryInfo dir )
        {
            // On some occasion, the DirectoryInfo.Create() function will
            // throw an error due to a bug in the .Net Framework design. For
            // example, it may happen that the user has no permissions to
            // list entries in a lower level in the directory path, and the
            // Create() call will simply fail.
            // To workaround it, we use mkdir directly.

            ArrayList oDirsToCreate = new ArrayList();

            // Check the entire path structure to find directories that must be created.
            while ( dir != null && !dir.Exists )
            {
                oDirsToCreate.Add( dir.FullName );
                dir = dir.Parent;
            }

            // "dir == null" means that the check arrives in the root and it doesn't exist too.
            if ( dir == null )
                throw ( new System.IO.DirectoryNotFoundException( "Directory \"" + oDirsToCreate[ oDirsToCreate.Count - 1 ] + "\" not found." ) );

            // Create all directories that must be created (from bottom to top).
            for ( int i = oDirsToCreate.Count - 1 ; i >= 0 ; i-- )
            {
                string sPath = (string)oDirsToCreate[ i ];
                int iReturn = _mkdir( sPath );

                if ( iReturn != 0 )
                {
            #if DEBUG
                    throw new ApplicationException( "Error calling [msvcrt.dll]:_wmkdir(" + sPath + "), error code: " + iReturn );
            #else
                    ConnectorException.Throw( Errors.AccessDenied );
            #endif
                }
            }
        }