Memory mapped file strange result

faustf

Member
Joined
Oct 8, 2020
Messages
5
Programming Experience
1-3
hi guys , i have created a memory mapped file , (without real file) in C# (sender txt),and i must read this file by other language mql4 (is similar to C++) (receiver Txt), the program work but return me ????? , i suppose probably C# encode data in unicode and mql4 is not full compatible with unicode (this a fact ), therefore i Encode in Ascii a C# text but also in this mode , it return me always ?????? any one have idea ? .
P.S. , if i use like sender C++ program all work perfect , but obviously i must do it in C#
C# sender Txt:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO.MemoryMappedFiles;
using System.ComponentModel;
using System.Windows.Input;
using System.IO;

namespace MemoryMappedCS_1
{
    class Program
    {
        static void Main(string[] args)
        {
            var file = MemoryMappedFile.CreateOrOpen("Test", 1000,MemoryMappedFileAccess.ReadWrite);
            try
            {
                byte[] de = Encoding.ASCII.GetBytes("Demade");
                MemoryMappedViewAccessor accessor = file.CreateViewAccessor();
                accessor.Write(0, (char)de.Length);
                accessor.WriteArray(0,de,0,de.Length);
             }
            catch
            {

            }
                Console.WriteLine("Run memory mapped file reader before exit");
                Console.WriteLine("Press any key to exit ...");
                Console.ReadLine();
        }
    }
}
 
Back
Top Bottom