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));
        }