Cannot open long file path

Hello Experts,

I cannot open long file path with _wfopen_s() and FindFirstFile().

A long file path means "C:\aaaaaaa....\bbbbb....txt"(260 bytes).

Windows 7 32bit, C++Builder XE2

Please advice.
NobMiwaAsked:
Who is Participating?
 
ZoppoConnect With a Mentor Commented:
Hi MobMiwa,

take a look at the section Maximum Path Length Limitation in this article: http://msdn.microsoft.com/en-us/library/windows/desktop/aa365247%28v=vs.85%29.aspx

There you can find the maximum length for a path is 260 incluind drive letter and terminating NUL character.

To use longer paths you have to use the UNICODE versions of the functions and prefix the path with a \\?\. According to ozo's comment you path should then look like i.e. this: "\\\\?\\C:\\aaaaaaa....\\bbbbb....txt".

Hope that helps,

ZOPPO
0
 
ozoCommented:
in C++ "\a" is an alert character, and "\b" is a backspace character.
Did you mean  "C:\\aaaaaaa....\\bbbbb....txt"?
0
 
NobMiwaAuthor Commented:
Thank you for reply.

Yes, I mean "C:\\aaaaaaa....\\bbbbb....txt" in code.
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
NobMiwaAuthor Commented:
Thank you for reply ZOPPO.

What do you mean "UNICODE versions of the functions" ?
Can I use _wfopen_s() ? If not, how can I open and read a file ?
0
 
Minh Võ CôngCommented:
Yes, I mean "C:\\aaaaaaa....\\bbbbb....txt" in code -> you can try the full path file, example "C\\aaaaaaaaaaaaaa\\bbbbbbbbb.txt,
you can use "C:\\aaaaaaa....\\bbbbb....txt" in console application.
0
 
ZoppoCommented:
Hm - I'm not really sure because I never used it this way, but I guess it should work with _wfopen_s since this is a wide-character version of fopen_s.

If it doesn't work you can use API functions like CreateFileW/ReadFileW/WriteFileW and FindFirstFileW/FindNextFileW/FindClose if your application doesn't use UNICODE.

ZOPPO
0
 
NobMiwaAuthor Commented:
Thank you for super quick reply !
0
All Courses

From novice to tech pro — start learning today.