Solved

make new folder

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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

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…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

757 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now