I need Help with File FileInputStream and FileOutputStream


#1

I’m almost finshed creating a mixer. i want to save the settings for each of the channels at close then read from the temp file when the program is reopened so it opens with the last settings.

I’m totaly unfamiliar with the file classes can any one give me suggestions on how to acompish this?

Thanks


#2

I’d recommend using the PropertiesFile class instead of writing to a file manually.


#3

Thanks i’m looking into it now.

i have a few questions.

I know that this class wasnt intented for big values. i have about 16 double values 17 bool values and 11 string values do you think this is with in the limits of this class?

Also i saw thats this class is intended to write to the file shortly after a paramater is changed. i’d rather just take a snap shot of the settings as the program is closed is it possable to do this is i set the millisecondsBeforeSaving to -1?

Thanks


#4

I think it’ll cope with a lot more than that!

see the ensureWrittenToFile() method and the destructor - it’s all explained in there.


#5

Thanks for the advice one more stupid question

Is it possable to create a file relitive to where the exe file is so i dont have a specify an absolute path on the system.

thanks


#6

Ok i figured it out

thanks for the pointers


#7

I do have one more question.

the code below seems to work fine. It creates a file in the same directory as the executable after the application is shut down.

a problem i’m having is i need to check to see if the file exist on the harddrive so i can initialize some settings. problem is when i try to check using “TempStateFile->exsistsasfile()” it allways evaluates true even if the file hasn’t actualy been written to the harddrive yet

anyone have any suggestions?

TempStateFile = new File(File::getCurrentApplicationFile());

TempStateFile->setAsCurrentWorkingDirectory();

saveSet = new PropertiesFile(TempStateFile->withFileExtension(T(“mxt”)), 0 , false,false);[/code]


#8

er… maybe you meant this:

File stateFile (File::getCurrentApplicationFile().withFileExtension(T(“mxt”)));
saveSet = new PropertiesFile (stateFile, 0, false, false);

It’s very bad to save anything in the application’s directory though. Tut tut. Very old-fashioned.


#9