Solved

Searching for files in path longer than 255 characters

Posted on 2002-03-10
13
408 Views
Last Modified: 2010-05-18
Hi there,

I am looking for a FindFirst, FindNext equivalent to find files and directories even if the path is longer than 255 characters.

I was trying to use the FindFistFileW function and prefixing the path name with "\\?\", however, I always get error code 3.

I'll give 300 points for some working code, it's urgent.

In a nutshell: I need to be able to search for directories and files even if the path name is longer than 255 characters.


Thanks,
Oliver
0
Comment
Question by:novowi
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
13 Comments
 
LVL 20

Expert Comment

by:Madshi
ID: 6854688
It works fine for me with "\\?\C:\boot.ini" (I don't have such long pathes on my PC) - but only in NT based systems! I guess you're trying it in win9x? That is not supported there. If you need this stuff for win9x, then you will probably have to deal with IShellFolder and that stuff...   :-(

Regards, Madshi.
0
 

Author Comment

by:novowi
ID: 6854695
Thanks Madshi,

I am running it on NT4 and W2K, not W95/98.

Regards,
Oliver
0
 

Author Comment

by:novowi
ID: 6854700
Madshi,

Does your madSecurity etc. work with such long file and path names ?

Thanks,
Oliver
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:novowi
ID: 6854767
Madshi,

Does your madSecurity etc. work with such long file and path names ?

Thanks,
Oliver
0
 
LVL 20

Expert Comment

by:Madshi
ID: 6854777
I've not tested it yet. Perhaps madShell can do that, madShell encapsulates the IShellFolder stuff. See here for documentation:

http://help.madshi.net/Data/madShell.htm

However, I think it should work with that \\?\. Can you show a short piece of your code?

Regards, Madshi.
0
 
LVL 20

Accepted Solution

by:
Madshi earned 300 total points
ID: 6854781
P.S: Does it work with your code, when you use that \\?\ on a short path, like e.g. '\\?\C:\*.*'?
0
 

Author Comment

by:novowi
ID: 6854788
Unfortunately not :(

Is there anything you can do about ?

Thanks,
Oliver
0
 

Author Comment

by:novowi
ID: 6854812
By the way, I solved the problem with the FindFirstFileW function. Used the wrong variable type.

However, two problems remain.
- Using madSecurity with such long dir/file names doesn't work.

- Using the FindFirstFileW function uses the wrong character set. I need to get the file names returned in OEM
and the SetFileAPIsToOEM function does not help. It works only if I use the normal FindFirst and Findnext functions.

Regards,
Oliver
0
 
LVL 20

Expert Comment

by:Madshi
ID: 6854827
>> Using the FindFirstFileW function uses the wrong character set.

?  Converting from wide character to ansi is very easy. Something like this:

var w32fd : TWin32FindDataW;
    str   : string;
begin
  ...
  str := wideString(w32fd.cFileName);

That's it. Or do you mean something different? I'm not sure.

And where exactly is the problem with madSecurity? Which call exactly fails? Some code, please!

Regards, Madshi.
0
 

Author Comment

by:novowi
ID: 6854832
By the way, I solved the problem with the FindFirstFileW function. Used the wrong variable type.

However, two problems remain.
- Using madSecurity with such long dir/file names doesn't work.

- Using the FindFirstFileW function uses the wrong character set. I need to get the file names returned in OEM
and the SetFileAPIsToOEM function does not help. It works only if I use the normal FindFirst and Findnext functions.

Regards,
Oliver
0
 
LVL 17

Expert Comment

by:inthe
ID: 6854867
i was following q wondering why you wouldnt get it to work as
i just tried FindFirstFileW on a path of 673 length and it worked ok as it should.


>>get the file names returned in OEM
now sure what that means but it wouldnt be:

Win32FindData.cAlternateFileName

would it?
0
 
LVL 34

Expert Comment

by:Slick812
ID: 6855400
this may help, I've used it to bypass real long file paths in some API functions that only take MAX_PATH charaters, but I don't remember which OS it will work under, I think NT, Win9x


function ShortPathName(const LongName: string): string;
var
  Buffer: array[0..MAX_PATH - 1] of Char;
begin
  SetString(Result, Buffer,
    GetShortPathName(PChar(LongName), Buffer, SizeOf(Buffer)));
end;
0
 

Author Comment

by:novowi
ID: 6862836
Madshi,

I did some thourough checking and your questions and suggestions finally helped me to sort it all out. It's all working.

Thanks,
Oliver
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question