473,399 Members | 4,254 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Retrieve proper filename case without using Directory.GetFiles()

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
3 4844
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Didier FRAISSE | last post by:
i need to retrieve every day an email and to save his attachments for later processing. i found some piece of code in the documentation like import poplib pop = poplib.POP3(Host)...
27
by: gmtonyhoyt | last post by:
I need assistance coming up with a clean way to handle filename extensions with my application. While I can come up with several ways of doing so on my own, I felt perhaps it would be worth...
4
by: Remco Ploeg | last post by:
Hi, I wan to fill a dropdownlist with the filenames in a certain directory, i use the following statement for retrieving the files: DirectoryInfo di = new...
10
by: Brian Gruber | last post by:
Hi, I'm looking for a way to rename a whole directory of files in short order. The files in the directory have different lengths, however all of them end with _xxxx the x's represent a randomly...
12
by: Lucas Tam | last post by:
I have a very simple loop: If (Directory.Exists(tempDirectory)) Then Try Dim Files() As String = Directory.GetFiles(tempDirectory) 'Clear out directory For Each Filename As String In Files...
12
by: David Beoulve | last post by:
In my windows C# app, I create a thread to separate the main code block from the GUI, which recursively sorts through all the directories starting from a given point, and every time it finds a...
3
by: Enyi | last post by:
Situation : Need to get a list of files in a directory, but I am currently getting the whole path of the file (Example: "C:\A Folder\Another Folder\file.txt"). What I want is just the filename and...
10
by: Roger Frost | last post by:
Since we are currently on the subject of multi-threading in a different thread, I have a question about delegates. When I use delegates, I just create one for each different parameter set that I...
15
by: Andy B | last post by:
I need to count files in a certain directory that has the string -Contract Template.xml at the end of it. How would I do this?
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.