EA - Creating textfile to other directory

 

Hi guys,

Can anybody help me out?

I used to have an EA that make use of kernel32.dll's CreateFileA & WriteFile function to output a textfile to my desktop. It was perfectly working before build 600. After the patch, the EA could not output the textfile anymore. I understand that FileWrite() function will only output the textfile to \MQL4\Files folder which is not what I wanted.

   FileName = "C:\\Users\\Lenovo\\Desktop\\data.txt";
   int hFile = CreateFileA(FileName,GENERIC_WRITE,FILE_SHARE_READ,0,CREATE_ALWAYS,0,0);    
   if(hFile!=INVALID_HANDLE)
   {
      string Buffer="Testing";
      int BytesWritten[1];
      BytesWritten[0]=0;
      int FileLength = StringLen(Buffer);      
      WriteFile(hFile,Buffer,FileLength,BytesWritten,0);
      CloseHandle(hFile);
   }
   else
   { 
      Print("Failed to clear datafile.");
   }
 
linearity:

Hi guys,

Can anybody help me out?

I used to have an EA that make use of kernel32.dll's CreateFileA & WriteFile function to output a textfile to my desktop. It was perfectly working before build 600. After the patch, the EA could not output the textfile anymore. I understand that FileWrite() function will only output the textfile to \MQL4\Files folder which is not what I wanted.

Have you tried using the Unicode version of your DLL based function ?
 
I think the kernell32 method was from https://www.mql5.com/en/articles/1540 and is outdated? Is there any other way of creating textfile in desktop?
 
linearity:
I think the kernell32 method was from https://www.mql5.com/en/articles/1540 and is outdated? Is there any other way of creating textfile in desktop?


Google is your friend . . .

From here: http://msdn.microsoft.com/en-us/library/windows/desktop/aa363858(v=vs.85).aspx

Unicode and ANSI names

CreateFileW (Unicode) and CreateFileA (ANSI)
Reason: