Exemple #1
0
        public static string ToShortName(string longName)
        {
            if (longName.IsNullOrWhiteSpace())
            {
                return(longName);
            }

            StringBuilder s = new StringBuilder(1000);

            longName = ChoPath.GetFullPath(longName);
            uint iSize = (uint)s.Capacity;
            uint iRet  = ChoKernel32.GetShortPathName(longName, s, iSize);

            return(s.ToString());
        }
Exemple #2
0
        public static string ToShortFileName(string filePath)
        {
            if (filePath.IsNullOrWhiteSpace())
            {
                return(filePath);
            }

            StringBuilder s = new StringBuilder(1000);

            filePath = ChoPath.GetFullPath(filePath);
            string directory = Path.GetDirectoryName(filePath);
            string fileName  = Path.GetFileName(filePath);

            uint iSize = (uint)s.Capacity;
            uint iRet  = ChoKernel32.GetShortPathName(directory, s, iSize);

            return(Path.Combine(s.ToString(), fileName));
        }
Exemple #3
0
        public static bool IsDirectory(string path)
        {
            if (path.IsNullOrWhiteSpace())
            {
                return(false);
            }

            path = ChoPath.GetFullPath(path);
            if (File.Exists(path))
            {
                return(false);
            }
            else if (Directory.Exists(path))
            {
                return(true);
            }
            else
            {
                return(Path.GetExtension(Path.GetFileName(path)).IsNullOrEmpty());
            }
        }