SRL Archive - OSR Help

SaveDataToFile


xtrapsp

2012-11-16 19:22:20

Hey guys,

Just wondering if you could help me out. Don't want to post the whole script so heres the necessary snippets:

procedure SaveDataToFile(file,text:string);
var
SaveFile, thefile: Integer;
Str: string;
begin
if FileExists(file) then
begin
thefile := OpenFile(file,true);
ReadFileString(thefile,str, FileSize(thefile));
CloseFile(thefile);
end;
SaveFile := RewriteFile(file, False);
if str = '' then
WriteFileString(SaveFile,text)
else
begin
WriteFileString(SaveFile,str + chr(13) + text);
end;
Writeln('Saved to: '+file);
CloseFile(SaveFile);
end;

SaveDataToFile('C:\Simba\Scripts\Logs', mailfirstname + IntToStr(k) + mailextension); 

Whenever I run it, this is the error I get:

ReWriteFile - Exception. Could not create file: C:\Simba\Scripts\Logs
Error: Exception: Invalid FileNum passed: -1 at line 84


Not sure why its trying to ReWrite the file straight off.. any suggestions?

Thanks guys

riwu

2012-11-16 20:05:20

Your argument:
SaveDataToFile('C:\Simba\Scripts\Logs', mailfirstname + IntToStr(k) + mailextension);
The path must specify a file name ;)
eg. C:\Simba\Scripts\Logs\abc.txt.

xtrapsp

2012-11-16 21:24:16

From: riwu
Your argument:
SaveDataToFile('C:\Simba\Scripts\Logs', mailfirstname + IntToStr(k) + mailextension);
The path must specify a file name ;)
eg. C:\Simba\Scripts\Logs\abc.txt.


tyvm :)