Solved

make new folder

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to determine file rename from EventLog ? 2 41
ShiftLeft challenge 21 76
sumHeights  challenge 17 65
wordcount challenge 11 102
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
Concerto provides fully managed cloud services and the expertise to provide an easy and reliable route to the cloud. Our best-in-class solutions help you address the toughest IT challenges, find new efficiencies and deliver the best application expe…

930 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

13 Experts available now in Live!

Get 1:1 Help Now