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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T03:09:53+00:00 2026-06-15T03:09:53+00:00

I am trying to create a text file through my code. The file is

  • 0

I am trying to create a text file through my code. The file is created but its extension is different(not .txt). Then on searching i came to know that this can be because of MFC runtimes.

I searched for the MFC Runtimes in my C:\program Files\Windows CE tools\SDK but i am not able to find the MFC folder there. What should i do? from where should i include MFC Runtimes?

here’s the text file generation code which i am using:

 void CFormRight::OnBnClickedButtonTextfile()
 {
    CFile File;
    char cFileAddr[100] = {"My Device\\Label.txt"};
    File.Open((LPCTSTR)cFileAddr, CFile::modeCreate | CFile::typeBinary |CFile::modeWrite | CFile::shareDenyNone);
    File.Write("Hello World", 15);
    File.Close();       
 }
  • 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-15T03:09:54+00:00Added an answer on June 15, 2026 at 3:09 am

    If you’re just looking for the DLLs, try looking on your development machine here:

    %PROGRAM_FILES%\Microsoft Visual Studio 9.0\VC\ce\dll

    That gets you the actual libraries. Including them in the OS image can be done a variety of ways. Typically you’d add them to your platform or project BIB file.

    Even with all of that, though, I don’t think it’s going to solve your problem of a file extension. If you’re creating a file and it shows up, just without an extension, it has nothing to do with MFC being there or not, it has to do with either your code, or the way you’re determining there is no extension (is “hide file extensions” turned on in Explorer?). To solve that problem, we’d need to see code.

    ** Edit **

    Windows CE is heavily biased toward Unicode. Nearly all Win32 APIs only have the Unicode variant exposed, therefore your code should also lean toward Unicode, meaning string you pass around that will end up at API calls should be Unicode.

    Second, you should not ignore the compiler when it complains. The cast you have in there I bet was due to a compiler complaint, and it’s just incorrect. If your original code was this (note the lack of cast on the first parameter):

    File.Open(cFileAddr, CFile::modeCreate | CFile::typeBinary |
                         CFile::modeWrite | CFile::shareDenyNone);
    

    Then you would get a compiler error:

    error C2664: 'CFile::Open' : cannot convert parameter 1 from 'char [100]' to 'LPCTSTR'

    That’s because under Windows CE, Open is looking for a wide (Unicode) string. You have an ANSI string. You cannot convert from ANSI to Unicode through a simple direct cast like you did. Yes, the compiler will quit complaining, but it gives bad behavior. You can cast an int to a char[] too, but that doesn’t mean it will work for the API.

    So change your code to use wide strings and all will work:

    CFile File;
    CFileException ex;
    wchar_t cFileAddr[100] = TEXT("My Device\\Label.txt");
    if(!File.Open(cFileAddr, CFile::modeCreate | CFile::typeBinary | 
                         CFile::modeWrite | CFile::shareDenyNone))
    {
        wchar_t error[1024];
        ex.GetErrorMessage(error, 1024);
        cout << "Error opening file: ";
        cout << error;
        return;
    }
    
    File.Write("ID Technologies", 15);
    File.Close();       
    

    Note the use of wchar_t, the initialization using the TEXT macro, and the lack of the cast in the Open call.

    EDIT 2

    I added error handling in the code above, but really you should learn to read the documentation and how to debug. This is a pretty basic usage scenario, and knowing how to look for errors is critical.

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

Sidebar

Related Questions

I'm trying to create a program that takes a text file of c++ code
I am trying to create a text file using VB.Net with UTF8 encoding, without
Cross-post http://perlmonks.org/index.pl?node_id=979710 I'm trying to create a text file from some XML using Perl
Alright well I am trying to create a dictionary from a text file so
I am trying to implement vectorization of a text file...I have created a dictionary
I am trying to create a text highlight option for my website. But I
I am trying to create full text index but I am getting error which
I'm trying to create a function to read Morse code from one file, convert
I'm trying to create text in html, that once clicked, the the value of
I am trying to create a text-based game in Java similar to Zork and

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.