Solved

make new folder

Posted on 1998-10-28
3
226 Views
Last Modified: 2013-11-20
now i use visual c++5
i would like to know how i create new folder from my application (by write program).
(when i click at button on my dialog in my application it will create new folder for me)
and how to create new text file from my application.
please help me
thank you
0
Comment
Question by:wanlop
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 

Author Comment

by:wanlop
ID: 1323959
Edited text of question
0
 

Accepted Solution

by:
rakeshkalra earned 100 total points
ID: 1323960
Write the following code in the button click event for creating a directory

if(!CreateDirectory( "c:\\myPreviousDirectory\\MyDirectory", NULL))
{
   // handle error
}

Note that myPreviousDirectory should exist otherwise this call will fail.

Use CStdioFile class for creating a text file.

try
{
    CStdioFile myFile( "c:\\someDir\\MyFile", CFile::modeCreate | CFile::modeWrite | CFile::modeText );

    myFile.WriteString("Hello this is my file\n");
    myFile.WriteString("this is the second line\n");
    myFile.Close();
}
catch(CFileException ex)
{
  // handle exception
}
 

0
 

Expert Comment

by:rakeshkalra
ID: 1323961
Please make the following change in the answer:

Instead of CFile::modeText in

    CStdioFile myFile( "c:\\someDir\\MyFile", CFile::modeCreate | CFile::modeWrite | CFile::modeText );

write CFile::typeText

    CStdioFile myFile( "c:\\someDir\\MyFile", CFile::modeCreate | CFile::modeWrite | CFile::typeText );

Sorry for the mistake.

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Excel Use VBA to get user's Mac Address for their computer 5 405
unable to delete all specified values regedit 38 877
unix example issues 18 113
Authenticate using sesu from script 7 159
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
Suggested Courses

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question