[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Cannot open long file path

Posted on 2013-01-27
7
Medium Priority
?
732 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
7 Comments
 
LVL 85

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
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 

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

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

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

In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
What do responsible coders do? They don't take detrimental shortcuts. They do take reasonable security precautions, create important automation, implement sufficient logging, fix things they break, and care about users.
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.
Introduction to Processes

830 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