Solved

make new folder

Posted on 1998-10-28
3
225 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
  • 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Separate into files by filename 12 91
Whole sheet autoscrub still needed 19 53
FizzBuzz challenge 9 84
wordmultiple challenge 12 154
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

685 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