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 8256443
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T01:51:55+00:00 2026-06-08T01:51:55+00:00

I have an application that reads a set of data files and performs some

  • 0

I have an application that reads a set of data files and performs some model computations. The program does not need to modify the data files themselves, so I’m currently opening them with the read-only flag as shown below:

FILE* file;
if(_wfopen_s(&file, fname.c_str(), L"r") == 0)
...

I would like to have several instances of my program running at the same time, using the same set of data, but performing different computations on the data. None of my programs need to modify the data files. As the data files are very large, I can’t make separate copies of the data to use with each program.

I assumed that because I’m opening the files with read-only permissions, two programs could be reading from the same file at the same time. Instead, I get various errors along the lines of “the file could not be open because it is being used by another process”.

As my development environment is Windows 7, this question suggests it might be a matter of enabling read sharing. However, all of the answers in that thread rely on CreateFile, whereas I’m dealing with legacy code that was written with stdio.h.

Is there a way I can have several programs concurrently read from a file using the fopen class of functions?

  • 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-06-08T01:51:56+00:00Added an answer on June 8, 2026 at 1:51 am

    If you can change the fopen routine then try to replace fopen calls with _fsopen, for shared reading/writing. _fsopen is mscrt-specific.

    If you can use CreateFile, and don’t want to re-write all the legacy code for read/write, you can also try associating a FILE * with a winapi file handle. Use _open_osfhandle to get a file descriptor from a file handle returned by CreateFile, then use _fdopen to get a FILE * from that file descriptor.

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

Sidebar

Related Questions

I have developed an application that reads files from the folder chosen by the
I have an application that imports data read from text files from a directory
I have a simple application that reads data in small strings from large text
I have an iPhone application that reads RSS feeds from a YouTube channel. However,
I have a Silverlight application that reads its content from an XML file. The
I have an service application that reads a config file containing a list of
I have a windows forms application that reads and updates an XML file with
I have to write a C++ application that reads from the serial port byte
I have created an application that connect on a web-server and reads an xml
In my rails application I have a rake task that reads emails using imap.

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.