Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7601857
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T23:15:53+00:00 2026-05-30T23:15:53+00:00

I wrote a small program which frequently opens small, user text files and until

  • 0

I wrote a small program which frequently opens small, user text files and until now haven’t encountered any problems with read/write access or any sorts of conflict. The files are selected in another piece of software which I have no control over, and are passed to me as a string.

When attempting to open a file from a mapped network drive I am getting a “The system cannot find the path specified” error (GetLastError() = 3).

The call is shown below, *iNCfileName = "z:\\Validation\\Sample Files\\1_1-4 120MM.CC", where Z: is a mapped folder on our domain.

iNCfile = CreateFile( iNCfileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, NULL);
if ( iNCfile == INVALID_HANDLE_VALUE ) 
{
    string msg; // lots of better ways to get this printed ... but ...
    dw = GetLastError();
    msg = iNCfileName;
    msg += ": ";
    msg += _com_error(dw).ErrorMessage();
    print_error(dw , (char*)msg.c_str() );
    return 102;
}

The file opens from my program if I copy it to the local hard drive. It also opens in notepad from the mapped drive.

Could this be a problem between the “Z:\whatever.txt” mapped representation and the true file name (\mydomain\Validation\S….??)?

If so, how can I convert from one to the other in a programmatic way (assume I won’t know the domain/share names ahead of time)?

If it makes any difference I use VS2010 and the application executes on a Win XP machine.

Related: my follow up question

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T23:15:55+00:00Added an answer on May 30, 2026 at 11:15 pm

    I’ve encountered this before. When using a path like \\DOMAIN\PATH\FILE.TXT I had to first call WNetAddConnection2().

    Here is my code (of course you can exclude the NULL members):

    NETRESOURCE nr = {0}; //new structure for network resource
    nr.dwType = RESOURCETYPE_ANY; //generic resource (any type allowed)
    nr.lpLocalName = NULL; //does not use a device
    nr.lpRemoteName = "\\\\DOMAIN\\PATH\\FOLDER"; //For me, this pointed to an account's documents folder, and from there I could use a subfolder
    nr.lpProvider = NULL; //no provider
    
    DWORD ret = WNetAddConnection2 (&nr, NULL, NULL, CONNECT_TEMPORARY); //add connection
    

    Don’t forget the header and library.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wrote a small program, that creates files at an interval of 1 minute.
I wrote a small program for iterating through a lot of files and applying
I wrote a small program in eclipse -android.Now i installed and i am running
I wrote a small program, kind of specialized HTTP server in haskell, which is
I would like to write a small program in C# which goes through my
I wrote a small program to test accessing a widget parent's slot. Basically, it
So I wrote a project-management program for a small business using Microsoft Access 2007.
I wrote a small program that uses Mechanize to traverse a site. I want
I wrote a small program using a custom indexOf function but wanted to dismiss
I wrote a small MATLAB program with a gui. Inside the gui I have,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.