Connecting Tech Pros Worldwide Help | Site Map

Getting File Properties info

Member
 
Join Date: Nov 2007
Posts: 49
#1: May 17 '08
Hi,

is there any API for
I have file in system stored as C:\TEMP\TEST.DATA.
Need to get the exact name (as store in system including case sensitive), suppose if i pass file name as c:\temp\test.data or handle to that file.

Basically wanted to retrieve the file name as stored in system rather than if user specifies c:\temp\test.data (as user can give in any format).

Bye
gpraghuram's Avatar
Expert
 
Join Date: Mar 2007
Location: Chennai
Posts: 1,256
#2: May 20 '08

re: Getting File Properties info


Quote:

Originally Posted by sudhivns

Hi,

is there any API for
I have file in system stored as C:\TEMP\TEST.DATA.
Need to get the exact name (as store in system including case sensitive), suppose if i pass file name as c:\temp\test.data or handle to that file.

Basically wanted to retrieve the file name as stored in system rather than if user specifies c:\temp\test.data (as user can give in any format).

Bye

R u trying this on windows?
Because windows 98 and previous versions has this behaviour(.i am not very sure about it)
And that too only for files more than 8 characters in length.

Raghuram
Member
 
Join Date: Nov 2007
Posts: 49
#3: May 20 '08

re: Getting File Properties info


My requirement goes something like this.
if user enters (in UI) c:\temp\test.txt , but actually system storage is as c:\TEMP\TEST.TXT(observe case sensitive). Here my application takes the backup of this file and there is finally facility to restore the same file.
So on restore, i wanted to create folder c:\TEMP(case sensitive) and TEST.TXT in that folder.

SO during backup statge i want to use c:\TEMP\TEST.TXT (rather than c:\temp\test.txt user entered in UI . here issue is case sensitive and i want to extract the file property as defined on the system). Hope my requirement is clear now.
gpraghuram's Avatar
Expert
 
Join Date: Mar 2007
Location: Chennai
Posts: 1,256
#4: May 20 '08

re: Getting File Properties info


Quote:

Originally Posted by sudhivns

My requirement goes something like this.
if user enters (in UI) c:\temp\test.txt , but actually system storage is as c:\TEMP\TEST.TXT(observe case sensitive). Here my application takes the backup of this file and there is finally facility to restore the same file.
So on restore, i wanted to create folder c:\TEMP(case sensitive) and TEST.TXT in that folder.

SO during backup statge i want to use c:\TEMP\TEST.TXT (rather than c:\temp\test.txt user entered in UI . here issue is case sensitive and i want to extract the file property as defined on the system). Hope my requirement is clear now.


I am not very sure an API is avialable for this.
In windows the file name is case insensitive....
I am not very sure an API exists for this.
Other members please comment on this

Raghuram
Needs Regular Fix
 
Join Date: Sep 2007
Location: The Netherlands
Posts: 427
#5: May 20 '08

re: Getting File Properties info


As gpraghuram said that should be impossible in windows since it's case-insensitive, which raises the question of why you would want to do this since filenames differing only in their case are indistinguishable?
Of course, you could try to read the file allocation table of the hard disk directly to determine the case of the filename but that's a whole other kettle of fish. If you're really interested in that, there are some code snippets out there which will help you. Do a google search on "how to access partition" or "low level hard disk access".
Member
 
Join Date: Nov 2007
Posts: 49
#6: May 21 '08

re: Getting File Properties info


I just want something like this:
User enters c\temp\temp.txt in UI. But tools provides option to backup the user mentioned file. Also restore back the file in similar structure.
In actual, if file is c\TEMP\TEMP.txt on backup and restore, i wanted to have similar directory structure (respecting case sensitive) in destination pc.
Finally c:\TEMP\TEMP.txt is to be backedup and deploy on other PC with same strucutre (though user mentioned like c:\temp\temp.txt during capture operation)
Member
 
Join Date: Nov 2007
Posts: 49
#7: Jun 24 '08

re: Getting File Properties info


Hi,

Want to retrieve the filename as reside in the disk respecting case info.
Eg: c:\temp\imp\data.doc (if this how the file stored in disk) and
is there any API thru which i can get the actual file case info if i give the path as c:\TEMP\IMP\DATA.DOC ( should return c:\temp\imp\data.doc as residing in the disk).

Bye
gpraghuram's Avatar
Expert
 
Join Date: Mar 2007
Location: Chennai
Posts: 1,256
#8: Jun 24 '08

re: Getting File Properties info


I think this is already posted in this forum...

Thanks
raghuram
Member
 
Join Date: Nov 2007
Posts: 49
#9: Jun 24 '08

re: Getting File Properties info


Yes. but there was no approach found.
gpraghuram's Avatar
Expert
 
Join Date: Mar 2007
Location: Chennai
Posts: 1,256
#10: Jun 25 '08

re: Getting File Properties info


Quote:

Originally Posted by sudhivns

Yes. but there was no approach found.


Can other experts comment on this?

Raghu
Newbie
 
Join Date: Jun 2008
Location: Houston, TX
Posts: 3
#11: Jun 26 '08

re: Getting File Properties info


Sorry for the late response, I'm rather new to the site.

Although Win32 is case insensitive it does respect the case of file names. The FindFirstFile() API may be used to determine the correct case of the desired file name. Note that this also works for retrieving the correct case for directory names, but each piece of a path name would have to be checked separately.
Newbie
 
Join Date: Jun 2008
Location: Houston, TX
Posts: 3
#12: Jun 26 '08

re: Getting File Properties info


Although Win32 is case insensitive it does respect the case of file names. The FindFirstFile() API may be used to determine the correct case of the desired file name. Note that this also works for retrieving the correct case for directory names, but each piece of a path name would have to be checked separately.
Member
 
Join Date: Nov 2007
Posts: 49
#13: Jul 31 '08

re: Getting File Properties info


!!!! Yes it is solved now.!!!!

Path = "c:\temp\data\read.txt" (actually it is stored in disk as c:\TEMP\DATA\READ.TXT)

use GetShortPathName() over Path and use the return short path name in GetLongPathName(), which results in exact case of of the path u r intended. (i.e c:\TEMP\DATA\READ.TXT)
Banfa's Avatar
AdministratorVoR
 
Join Date: Feb 2006
Location: South West UK
Posts: 6,162
#14: Jul 31 '08

re: Getting File Properties info


Threads Merged, Please Don't double post

Banfa
Administrator
Reply