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

  • Home
  • SEARCH
  • 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 9281475
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T18:07:50+00:00 2026-06-18T18:07:50+00:00

This is a very odd error. I am using Visual Studio 2012, and in

  • 0

This is a very odd error.

I am using Visual Studio 2012, and in a C++ project (as a container for a C project), I am loading a file in this way:

const char* fname = "SomeFile.csv";
if(!(fp = fopen(fname, "r")))
{
    printf("Error! Could not open %s!\n",fname);
    return;
}

The CSV is in the same folder as the .EXE, and that is the intention for this program.

1. When I run it in debug, it fails to read the CSV.

2. When I put in the full pathname to the file, it works correctly and loads the CSV.

3. When I go to the output folder in Windows Explorer, and run the .exe, it correctly loads the CSV.

4. Now here is the weird part. When I go to another folder (anywhere else), and I then paste in the full path including the .exe into Windows Explorer, it starts up the program, as it should, but it fails to read the CSV.

As a caveat, if I have the folder loaded in explorer, but run it in the VS2012 debugger, it also fails to load the CSV.

What is going on here? Why would it only find it if I am running it while the window is open in explorer?

  • 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-18T18:07:51+00:00Added an answer on June 18, 2026 at 6:07 pm

    fopen, open, etc. will, given a bare filename with no path components, attempt to open the named file in the “current directory”. Given a filename without a filesystem root it will attempt to open the file in a directory relative to the current directory. Only when given an absolute (full) path will it look exactly where you’ve told it.

    In a command-line based system, the current directory is pretty obvious – it’s the directory you are in when you issue the command.

    In a Graphical User Interface the notion of a current directory is a bit more mushy:

    • Navigate in Windows explorer to the program (let’s say WORD.EXE) and double click it – the current directory is likely to be the directory where the program is – the place to which you navigated (but there’s no standard that says this has to be the case)
    • Navigate to your documents for your project and double click a Word document, which launches WORD.EXE automatically – what is the current directory? It’s likely to be where the document is.
    • Launch WORD.EXE from the Start menu – what the heck is the current directory now?
    • Launch your program from the debugger – now what is the current directory?

    This last point is why you have to tell the IDE / debugger what to use as the current directory when it launches your program.

    The fileOpenDialog doesn’t exactly “default” to the current directory – it open to where you last opened it, without changing the current directory for the program – when you pick a file it then passes the full path of that file to the program.

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

Sidebar

Related Questions

This very simple code: #include <iostream> using namespace std; void exec(char* option) { cout
I've got this very odd bug that appears to be a quirk in Visual
I'm getting a very odd error using a basic shortcut method in python. It
This is very odd. I've written a windows form tool in C# to return
This is very odd. I have never had this issue with ShowDialog in C#.
This is a very odd one and I'm not sure how to proceed. Basically,
Right, this is a very odd issue that I'm wondering how i am going
I am doing very simple int division and I am getting odd results. This
I am having a very odd error occurring in the following: class ServeHandler(blobstore_handlers.BlobstoreDownloadHandler): def
i just added dependency to eclipse birt to my project now very odd failures

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.