Error 5002

 

Hi , I am getting error 5002 from trying to write this filename:

filename = IntegerToString(AccountNumber())+": "+Symbol()+" "+date+" - ask.bin";
file_handle=FileOpen(filename,FILE_WRITE|FILE_BIN); 
if(file_handle!=INVALID_HANDLE) 
{ 
        FileWriteArray(file_handle,ask, 0, WHOLE_ARRAY); 
        FileClose(file_handle); 
}
else
{
        Print(GetLastError());
}

This error did not pop up until I added this portion:

IntegerToString(AccountNumber())

I tried to just use AccountNumber() by itself but I got a compile error of implicit conversion from 'number' to 'string'.  Is there a proper way to doing this?

thank you

 

I'm absolutley stumped.  Anytime I am trying to write Account information to the filename, including AccountInfoString(ACCOUNT_COMPANY), I am getting Error 5002.  Otherwise, it works.

 

Print out filename variable and check that it is a valid windows file name.

You have "date" variable - check if there is "/" in the filename.

 
Hoi Cheng: I am getting error 5002 from trying to write this filename:
filename = IntegerToString(AccountNumber())+": "+Symbol()+" "+date+" - ask.bin";
  1. Filenames are C:\path\name.ext. Colon is a reserved character.
  2. As Drazen said, date could have slashes and colons (if it includes times.)
 
thank you!  that little colon was the issue!