By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,462 Members | 1,484 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,462 IT Pros & Developers. It's quick & easy.

Retrieve proper filename case without using Directory.GetFiles()

P: n/a
Is it possible to retrieve a proper/invariant file or directory name using a
lowercase full path string without having to resort to a call to
GetDirectories()/GetFiles() using the directory/filename as the search
string? While Path, FileInfo, and DirectoryInfo all store the path
information, they use the path case passed to them, so passing a lowercase
path to Path.GetFullPath() will return a lowercase full path. TIA
Jul 9 '08 #1
Share this Question
Share on Google+
3 Replies


P: n/a
On Jul 9, 3:37*pm, Devon <De...@discussions.microsoft.comwrote:
Is it possible to retrieve a proper/invariant file or directory name using a
lowercase full path string without having to resort to a call to
GetDirectories()/GetFiles() using the directory/filename as the search
string? While Path, FileInfo, and DirectoryInfo all store the path
information, they use the path case passed to them, so passing a lowercase
path to Path.GetFullPath() will return a lowercase full path. TIA
Hi,

Not that I know of,
just to confirm, do you want to get the path in the way it's in the
filesystem?
Jul 9 '08 #2

P: n/a
Right - given a full path in lowercase, I need to retrieve the path as
present in a local or remote filesystem, which will be, for the majority of
cases, NTFS

"Ignacio Machin ( .NET/ C# MVP )" wrote:
On Jul 9, 3:37 pm, Devon <De...@discussions.microsoft.comwrote:
Is it possible to retrieve a proper/invariant file or directory name using a
lowercase full path string without having to resort to a call to
GetDirectories()/GetFiles() using the directory/filename as the search
string? While Path, FileInfo, and DirectoryInfo all store the path
information, they use the path case passed to them, so passing a lowercase
path to Path.GetFullPath() will return a lowercase full path. TIA

Hi,

Not that I know of,
just to confirm, do you want to get the path in the way it's in the
filesystem?
Jul 9 '08 #3

P: n/a
Couldnt see a .NET way to do this as the FileInfo class uses the string you
give it to do fill the FullName property.
So I thought I would knock you up a class to do this. It calls the Windows
Api to get the proper name for each of the folders in the path and then the
file too. It might not be the most perfect implementation as I just knocked
it up for you in about 10 minutes.
I posted it on my blog (below) so let me know what you think.
--
Ciaran O''Donnell
http://wannabedeveloper.spaces.live.com
"Devon" wrote:
Right - given a full path in lowercase, I need to retrieve the path as
present in a local or remote filesystem, which will be, for the majority of
cases, NTFS

"Ignacio Machin ( .NET/ C# MVP )" wrote:
On Jul 9, 3:37 pm, Devon <De...@discussions.microsoft.comwrote:
Is it possible to retrieve a proper/invariant file or directory name using a
lowercase full path string without having to resort to a call to
GetDirectories()/GetFiles() using the directory/filename as the search
string? While Path, FileInfo, and DirectoryInfo all store the path
information, they use the path case passed to them, so passing a lowercase
path to Path.GetFullPath() will return a lowercase full path. TIA
Hi,

Not that I know of,
just to confirm, do you want to get the path in the way it's in the
filesystem?
Jul 10 '08 #4

This discussion thread is closed

Replies have been disabled for this discussion.