tags:

views:

41

answers:

1

In my MFC application project during runtime i want create a txt file and i want store some data in that i dont want to create the notepad file in any Hard drive. It must be in application only. when i click a IDC_BUTTON1 then it must open.then the user must decide wheather the txt file has to save in hard disk or not.

So how to create a notepad file during a execution and same file i have to open and read during the execution time.

+1  A: 

You do not need a file, you just need a variable in memory to hold the text. You can display this text in you GUI in a preview window.

If the user wants to save it, write the content of your variable to the disc. If you want to present this file to the user in his default text editor, you can perform a ShellExecute() on the file you just created.

Edit: You can invoke the function like this

ShellExecute(
  NULL, 
  "open", 
  <path_to_textfile>, 
  NULL, 
  NULL, 
  SW_SHOWNORMAL);
Treb
say the variable like temp holding data i used, how it can present default text editor using ShellExecute(),PlZ i dont have idea