コード例 #1
0
        /// <summary>
        /// Finds the on-disk case of a a file
        /// </summary>
        /// <param name="Info">FileInfo instance describing the file</param>
        /// <returns>New FileInfo instance that represents the file with the correct case</returns>
        public static FileInfo FindCorrectCase(FileInfo Info)
        {
            DirectoryInfo ParentInfo = DirectoryUtils.FindCorrectCase(Info.Directory);

            foreach (FileInfo ChildInfo in ParentInfo.EnumerateFiles())
            {
                if (String.Equals(ChildInfo.Name, Info.Name, FileReference.Comparison))
                {
                    return(ChildInfo);
                }
            }
            return(new FileInfo(Path.Combine(ParentInfo.FullName, Info.Name)));
        }
コード例 #2
0
 /// <summary>
 /// Finds the correct case to match the location of this file on disk. Uses the given case for parts of the path that do not exist.
 /// </summary>
 /// <param name="Location">The path to find the correct case for</param>
 /// <returns>Location of the file with the correct case</returns>
 public static DirectoryReference FindCorrectCase(DirectoryReference Location)
 {
     return(new DirectoryReference(DirectoryUtils.FindCorrectCase(Location.ToDirectoryInfo())));
 }