Example #1
0
        }   // private static method PathRemoveBackslash


        /// <summary>
        /// Extract the directory name from a fully qualified file name.
        /// </summary>
        /// <param name="pstrFQFN">
        /// String containing file name to evaluate.
        /// </param>
        /// <param name="penmTerminaBackslash">
        /// A member of the TerminaBackslash, which specifies whether the
        /// returned string should have a terminal backslash.
        /// </param>
        /// <returns>
        /// If the function succeeds, the return value is the directory name
        /// stripped of its file name.
        /// </returns>
        /// <see cref="TerminaBackslash"/>
        public static string FileDirName (
            string pstrFQFN ,
            TerminaBackslash penmTerminaBackslash )
        {
            if ( string.IsNullOrEmpty ( pstrFQFN ) )
                throw new ArgumentException (
                    WizardWrx.Common.Properties.Resources.ERRMSG_ARG_IS_NULL_OR_EMPTY ,
                    ARG_NAME_PSTRFQFN );

            if ( pstrFQFN.IndexOf ( Path.DirectorySeparatorChar ) == MagicNumbers.STRING_INDEXOF_NOT_FOUND )
                return SpecialStrings.EMPTY_STRING;

            return PathFixup (
                pstrFQFN.Substring (
                    MagicNumbers.STRING_SUBSTR_BEGINNING ,
                    pstrFQFN.LastIndexOf ( Path.DirectorySeparatorChar ) ) ,
                penmTerminaBackslash );
        }   // public static method FileDirName
Example #2
0
        }   // public static method MakeFQFN


        /// <summary>
        /// Originally a private method, this method returns a path (directory)
        /// name string that is guaranteed to meet the specified requirement,
        /// with respect to presence or absence of a terminal backslash.
        /// </summary>
        /// <param name="pstrInputPath">
        /// String containing path (directory) name to evaluate.
        /// </param>
        /// <param name="penmBackslash">
        /// A member of the TerminaBackslash, which specifies whether the
        /// returned string should have a terminal backslash.
        /// </param>
        /// <returns>
        /// Path (directory) name string that is guaranteed to either have, or
        /// omit, a terminal backslash, as specified.
        /// </returns>
        /// <see cref="TerminaBackslash"/>
        public static string PathFixup (
            string pstrInputPath ,
            TerminaBackslash penmBackslash )
        {
            if ( string.IsNullOrEmpty ( pstrInputPath ) )
                throw new ArgumentException (
                    WizardWrx.Common.Properties.Resources.ERRMSG_ARG_IS_NULL_OR_EMPTY ,
                    ARG_NAME_PSTRINPUTPATH );

            switch ( penmBackslash )
            {
                case TerminaBackslash.Include:
                    return PathAddBackslash ( pstrInputPath );
                case TerminaBackslash.Omit:
                    return PathRemoveBackslash ( pstrInputPath );
                default:
                    return PathAddBackslash ( pstrInputPath );
            }	// switch (penmBackslash)
        }   // public static method PathFixup