Solved

Cannot open long file path

Posted on 2013-01-27
7
718 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 500 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
Transaction Monitoring Vs. Real User Monitoring

Synthetic Transaction Monitoring Vs. Real User Monitoring: When To Use Each Approach? In this article, we will discuss two major monitoring approaches: Synthetic Transaction and Real User Monitoring.

 

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

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!

Question has a verified solution.

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

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

726 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