?
Solved

Cannot open long file path

Posted on 2013-01-27
7
Medium Priority
?
725 Views
Last Modified: 2013-01-28
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.
0
Comment
Question by:NobMiwa
[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
7 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 38825834
in C++ "\a" is an alert character, and "\b" is a backspace character.
Did you mean  "C:\\aaaaaaa....\\bbbbb....txt"?
0
 
LVL 31

Accepted Solution

by:
Zoppo earned 2000 total points
ID: 38825837
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
 

Author Comment

by:NobMiwa
ID: 38825838
Thank you for reply.

Yes, I mean "C:\\aaaaaaa....\\bbbbb....txt" in code.
0
Industry Leaders: 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:NobMiwa
ID: 38825854
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
 
LVL 15

Expert Comment

by:Minh Võ Công
ID: 38825890
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
 
LVL 31

Expert Comment

by:Zoppo
ID: 38825914
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
 

Author Closing Comment

by:NobMiwa
ID: 38826925
Thank you for super quick reply !
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
Make the most of your online learning experience.
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.
Suggested Courses

771 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