Problem with write to filename.txt

 

Hello all,

I need some coding help please. I am trying to write "Hello World" to text file "Test.txt". After running the code I check the file and nothing is there. Do I need a loop in here to write to the file?


void WriteToFile()
{
   string terminal_data_path=TerminalInfoString(TERMINAL_DATA_PATH); 
   int filehandle=FileOpen("Test.txt",FILE_WRITE|FILE_TXT); 
   if(filehandle!=INVALID_HANDLE) 
     { 
      string str = "Hello World";
      FileWriteString(filehandle,str); 
  
     // Print("FileOpen OK"); 
     } 
   else Print("Operation FileOpen failed, error ",GetLastError()); 
     FileClose(filehandle);
   }
 
I already test your code and it's working, please see these attachment
Files:
1.jpg  185 kb
2.jpg  135 kb
3.jpg  124 kb
4.jpg  98 kb
Test.txt  1 kb
 
Maybe you are looking at different folder, please see above picture : 1.jpg, 2.jpg, 3.jpg & 4.jpg
 
Biantoro Kunarto:
Maybe you are looking at different folder, please see above picture : 1.jpg, 2.jpg, 3.jpg & 4.jpg

I solved it already. I was looking at Logs\Test.txt instead of MQL4\Files\Test.txt.

Thank you for your time and assistance.


"The file is opened in the folder of the client terminal in the subfolder MQL4\files (or Tester\Files in case of testing). "
 
GrumpyDuckMan:

I solved it already. I was looking at Logs\Test.txt instead of MQL4\Files\Test.txt.

Thank you for your time and assistance.

You're welcome 
Reason: