Solved

Opening Files with UNC Names

Posted on 1997-10-15
1
714 Views
Last Modified: 2008-03-06
Is there a function in Microsoft Visual C/C++ 4.2 that will open a file if I send it:

\\SERVER\VOLUME\DIRECTORY\FILENAME

I am in the process of trying CreateFile, but it doesn't look like that supports UNC...

Any help would be greatly appreciated.

0
Comment
Question by:tward
1 Comment
 
LVL 5

Accepted Solution

by:
y96andha earned 100 total points
ID: 1255907
All functions I know in MSVC++ 4.0 support UNC paths. CreateFile does, open does, fopen does. There is even a note in the CreateFile documentation that you can enter UNC paths with lengths of up to 32k:

Windows NT: You can transcend this limit and send in paths longer than MAX_PATH characters by calling the wide (W) version of CreateFile and prepending "\\?\" to the path. The "\\?\" tells the function to turn off path parsing. This lets you use paths that are nearly 32k Unicode characters long. You must use fully-qualified paths with this technique. This also works with UNC names. The "\\?\" is ignored as part of the path. For example, "\\?\C:\myworld\private" is seen as "C:\myworld\private", and "\\?\UNC\tom_1\hotstuff\coolapps" is seen as "\\tom_1\hotstuff\coolapps".


But, with paths of normal lengths, you can just send them in.
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
stack 22 159
How do I install gcc 4.8.4 on a Linux Ubuntu 14.04 machine? 5 1,581
An API detour question 7 79
C++ :Change value from  DisableCMD registry 4 52
Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
The goal of this video is to provide viewers with basic examples to understand and use structures in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.

863 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now