Writing FIles produces strange files

 

Hi, when I use the FileWrite or FileWriteString, MT produces binary files, which are close to be text files.


Here is my code:


string msg = "\nTester duration: "+DoubleToString(double(end_time-init_time)/1000.0)+" sec";

  string file_name= "TestLog.txt";
   int file_handle = -1;
  file_handle=FileOpen(file_name,FILE_READ|FILE_WRITE|FILE_TXT);
   if(file_handle==INVALID_HANDLE)
    Print("Error opening rep-file: "+file_name);
//---
   FileSeek(file_handle,0,SEEK_END);
   FileWrite(file_handle,msg);
   FileWrite(file_handle, "\nErrors:");
   for (int i=0; i<err_log.size(); i++)
   {
    FileWrite(file_handle, "\n"+err_log.errors[i].msg);
   }
   FileFlush(file_handle);
   FileClose(file_handle);


Here is the result:

00000000  ff fe 0d 00 0a 00 54 00  65 00 73 00 74 00 65 00  |......T.e.s.t.e.|
00000010  72 00 20 00 64 00 75 00  72 00 61 00 74 00 69 00  |r. .d.u.r.a.t.i.|
00000020  6f 00 6e 00 3a 00 20 00  36 00 2e 00 39 00 33 00  |o.n.:. .6...9.3.|
00000030  38 00 30 00 30 00 30 00  30 00 30 00 20 00 73 00  |8.0.0.0.0.0. .s.|
00000040  65 00 63 00 0d 00 0a 00  0d 00 0a 00 45 00 72 00  |e.c.........E.r.|
00000050  72 00 6f 00 72 00 73 00  3a 00 0d 00 0a 00 0d 00  |r.o.r.s.:.......|
00000060  0a 00 70 00 6c 00 61 00  63 00 65 00 53 00 74 00  |..p.l.a.c.e.S.t.|
00000070  6f 00 70 00 4f 00 72 00  64 00 65 00 72 00 3a 00  |o.p.O.r.d.e.r.:.|
00000080  32 00 30 00 32 00 34 00  20 00 43 00 6f 00 64 00  |2.0.2.4. .C.o.d.|
00000090  65 00 3a 00 20 00 34 00  37 00 35 00 36 00 20 00  |e.:. .4.7.5.6. .|

This is how a text file should look like:

00000000  74 68 69 73 20 69 73 20  61 20 6e 6f 72 6d 61 6c  |this is a normal|
00000010  20 74 65 78 74 20 66 69  6c 65 2e 20 49 0a 64 6f  | text file. I.do|
00000020  6e 74 20 73 65 65 20 61  20 72 65 61 73 6f 6e 0a  |nt see a reason.|
00000030  77 68 79 20 4d 54 20 73  68 6f 75 6c 64 20 70 72  |why MT should pr|
00000040  6f 64 75 63 65 20 73 75  63 68 20 61 20 6d 65 73  |oduce such a mes|
00000050  73 79 20 6d 69 78 65 64  20 66 69 6c 65 2e 20 0a  |sy mixed file. .|
00000060  49 73 20 69 74 20 73 6f  6d 65 74 68 69 6e 67 20  |Is it something |
00000070  77 69 6e 64 6f 77 73 20  75 73 65 72 73 20 6c 6f  |windows users lo|



What do I miss?

 

solved:

This would have been the right combination of parameters.

file_handle=FileOpen(file_name,FILE_READ|FILE_WRITE|FILE_TXT|FILE_ANSI);