PDA

View Full Version : cannot create destination folder


slogan
03-11-2008, 01:35 AM
Hi Alain,

What is the way to create the folder, where I'd like to store or change a file?
I have something like this, but it doesn't work that way:
-------------------------
ToDay%=GetDate;
Date_extention%=Date2code(ToDay%);
File_location%= "\\My Documents\\"+Date_extention%+"\\";

File_path$=File_location%+File_Name%+".txt";
fp$ = fopen(File_path$, "w");
//do write some data into the file
fclose(fp$);
-------------------------
GetDate is my own func, which returns the date in "xx.xx.xx" format.
Date2code removes points from date, so it becomes "xxxxxx".

thanks for advise!

Slogan

PointOfLight
03-11-2008, 03:33 AM
After defining File_location%, do:

CreateDirectory(File_location%, NULL);

If you want some information on the second parameter, see the MSDN entry for CreateDirectory.

slogan
03-11-2008, 10:38 PM
And how could I check if the directory already exists? I this case I would change new directory name?

PointOfLight
03-12-2008, 03:18 AM
if(DirectoryExists(File_Location%))
* //Choose a different directory name
end;