System.IO.Win32File.LongFileName C# (CSharp) Méthode

LongFileName() public static méthode

public static LongFileName ( string filepath ) : string
filepath string
Résultat string
        public static string LongFileName(string filepath)
        {
            // If file path is disk file path then prepend it with \\?\
            // if file path is UNC prepend it with \\?\UNC\ and remove \\ prefix in unc path.
            if (filepath.StartsWith(@"\\"))
                return @"\\?\UNC\" + filepath.Substring(2, filepath.Length - 2);
            else
                return @"\\?\" + filepath;
        }

Usage Example

        public static bool Exists(string filepath)
        {
            uint attribs = GetFileAttributesW(Win32File.LongFileName(filepath));

            return((attribs != INVALID_FILE_ATTRIBUTES) && ((attribs & FILE_ATTRIBUTE_DIRECTORY) != 0));
        }