New guy questions: strings and files, using multiple times


Ok, I’m sure this is silly, but I can’t figure out how to use one String and one File variable to load multiple files. I couldn’t find a way to re-use a variable. Unless its not possible. If its not, ok, I can live with that. Just wondering about this…

Also, another thing. Do I need to clean up a String variable after I use and no longer need it? The same goes for a File variable, how do I close the file?

I’m using both as String and File. I tried to use as pointers, but couldn’t use, for instance, String * Path with File(Path) :oops:

Thanks, Wk


Here’s what I’m talking about. There must be a better way to do this…

[code] File xFile(File::getSpecialLocation(File::currentExecutableFile));
xFile = xFile.getParentDirectory();

String dPath3(xFile.getFullPathName());
dPath3.append(T("\\Wusik Red Fuse\\Skins\\"),99); dPath3.append(SkinName,99);
File fFile(dPath3);
if (fFile.existsAsFile()) newLookAndFeel->treeFolder = ImageFileFormat::loadFrom(fFile);

String dPath4(xFile.getFullPathName());
dPath4.append(T("\\Wusik Red Fuse\\Skins\\"),99); dPath4.append(SkinName,99);
File fFile2(dPath4);
if (fFile2.existsAsFile()) newLookAndFeel->treeFile = ImageFileFormat::loadFrom(fFile2);



Ok, I see that File doesn’t need to be closed, as its not like MS C++ File. :oops: that’s clear now. :wink:



There must be hundreds of places in the code where this kind of thing is done - just grep for “File” and “String” and do a bit of browsing around!


Thanks Jules. Don’t give up on me, I know I can be a PITA sometimes. :oops: Its just that I’m learning tons of stuff at the same time. :wink:



Don’t worry, it’s good to have n00b stuff on the board, there are probably a lot of other beginners lurking around the place who’d find it useful!