move or delete a Metatrader file in Linux

 

Hi,

 

I am using Metatrader 4 on Linux Wine. I have a file in the folder "/home/user/.wine/drive_c/Program Files (x86)/MetaTrader 4/MQL4/Files/xxx.csv"

 

I want MQL to delete this file or move the file to "/home/user/.wine/drive_c/Program Files (x86)/MetaTrader 4/MQL4/Files/OLD/xxx.csv" after reading. I have this code:


string m_filename="xxx.csv"; 

string src_path=StringConcatenate("/home/morry/.wine/drive_c/Program Files (x86)/MetaTrader 4/MQL4/Files/"+m_filename);

string dst_path=StringConcatenate("/home/morry/.wine/drive_c/Program Files (x86)/MetaTrader 4/MQL4/Files/OLD/"+m_filename);

bool moved=FileMove(src_path,0,dst_path,FILE_COMMON|FILE_REWRITE);

	if(moved)

     	{

           Print("File Moved");

        }

 

But this does not work.... How should I correct this code?

Thanks 

 

what about

bool moved=FileMove(m_filename,0,"OLD/"+m_filename.....);
 
morrysa7:

Hi,

 

I am using Metatrader 4 on Linux Wine. I have a file in the folder "/home/user/.wine/drive_c/Program Files (x86)/MetaTrader 4/MQL4/Files/xxx.csv"

 

I want MQL to delete this file or move the file to "/home/user/.wine/drive_c/Program Files (x86)/MetaTrader 4/MQL4/Files/OLD/xxx.csv" after reading. I have this code:


 

But this does not work.... How should I correct this code?

Thanks 

 


1) For reference, you can not navigate to any location on the file system. MT4 has this security constrain, as stated in:  https://docs.mql4.com/files/


2) You are using a windows program (mt4) within linux. Path names are different in linux than in windows.

Your default based directory for mt4 in linux is:

"/home/user/.wine/drive_c/Program Files (x86)/MetaTrader 4/MQL4/Files"


So, if you refer to a file xxx.csv with this path:

/home/user/.wine/drive_c/Program Files (x86)/MetaTrader 4/MQL4/Files/xxx.csv

then you could use just:

string src_path = "xxx.csv"


Now, you want to refer to destination OLD/ with following path

/home/user/.wine/drive_c/Program Files (x86)/MetaTrader 4/MQL4/Files/OLD/

Then use:

string dst_path = StringConcatenate("OLD\", "xxx.csv");

with backslash. That's it.


3) You could skip constrain 1) by creating links within the default directory to the desired files. (you probably can not create a single link to a whole directory in linux, as it is not longer allowed, even for superuser, so you would have to create a link for each individual file)

Reason: