Skip to main content
Known Participant
December 11, 2008
Question

create a text file

  • December 11, 2008
  • 4 replies
  • 533 views
Hi,

I m new to Indesign Programming.
(InDesign Programming CS3 on MAC OS X)

Can someone give me the code to create a .txt file? I saw that there are classes lik SDKFileSaveChooser, OpenChooser aand al. But I jus need to create a file in the path i specify and then write few things into it.

Can anyone help me with the code to create a .txt file in a fixed path(path of the appln folder)?

Pls guide me...

Thanks..
This topic has been closed for replies.

4 replies

Known Participant
December 11, 2008
IDFile file;
FileUtils::GetAppInstallationFolder(&file);
FileUtils::AppendPath(&file, PMString("CheckBox.txt", -1, PMString::kNoTranslate));
FileUtils::OpenFile(file, "wt");

Thanks a lot John.. It worked...
Known Participant
December 11, 2008
Thanks a lot for ur reply John...
I need to create a file... Is there any method to create files in IDFile.h....
I really donno much about this...if u don mind, Pls guide me ...
Participating Frequently
December 11, 2008
Hi,
You should use IDFile and standard IO in C.
See documentation and samples.
KatMusAuthor
Known Participant
December 11, 2008
I tried this:
AFile file;
AString path = "/Macintosh HD/Users/laser/Desktop/";
AString namePrefix = "PicIcoText.txt";
file.SetPath(path);
file.SetName(namePrefix);
file.MakeFile(true, NULL);
CAlert::InformationAlert("File created");

The alert is popped up, but file is not created. Is this correct to create a .txt file? or is there something with the way i specified the path...