Solved

Opening Files with UNC Names

Posted on 1997-10-15
1
716 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

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.

Question has a verified solution.

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

An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
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…
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.

770 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