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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:57:34+00:00 2026-05-29T05:57:34+00:00

I am working on a Windows VC++ 2008 project, and trying to use fileIO

  • 0

I am working on a Windows VC++ 2008 project, and trying to use fileIO to put stuff out in log files in a sub-directory. I am doing the following:

void MessageQueue::LogOut(thingEnum _thing){
    std::ofstream Output;
    Output.open("Output/MainLog.txt", std::ios::app);

    if (Output.is_open()){
        // writing stuff
    }
    Output.close();
}

I know that the ios::app will generate a file, but isn’t it also able to generate folders as well, or do I need a different command to generate a folder for the files to exist in. when I get rid of the sub-directory in the code it works fine, and if I create the folder I can put the sub-directory code back.

note: I understand that I should technically open the file buffer the same line that I create the stream object. I did not because I plan to put the .open into a case switch (_thing) to have access to multiple files, and just change the stream.

  • 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-29T05:57:35+00:00Added an answer on May 29, 2026 at 5:57 am

    You could use the _mkdir function before you call open.

    http://msdn.microsoft.com/en-us/library/2fkk4dzw(v=vs.90).aspx

    #include <direct.h>
    
    void MessageQueue::LogOut(thingEnum _thing){
    
        if (_mkdir("Output\\") == 0) {
            std::ofstream Output;
    
            Output.open("Output\\MainLog.txt", std::ios::app);
    
            if (Output.is_open()){
                // writing stuff
            }
            Output.close();
       }
       else {
            // could not create directory
       }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working with a Visual Studio 2008 (C#) project on Windows XP Pro.
I'm working on a project using Windows 2008, .NET 3.5 and WCF for some
I am working in Visual Studio 2008 and have a Windows Forms project +
We are working on a Windows Mobile 6.5 application in Visual Studio 2008. The
I'm working with visual studio 2008 developing software for windows CE 6.0, compact framework.
I'm working on a C# windows program with Visual Studio 2008. Usually, I work
For a small project that I'm working on I need to create a Windows
Working in .NET Compact Framework, C#, .Net 3.5, Visual Studio 2008. Targeting Windows Mobile
We have a database project in Visual Studio 2008 that has been working great.
I am working on a project in which I want to use the command

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.