string foo[4];
void OnStart() {
FolderCreate("abc", 0);
FolderDelete("abc", 0);
// Clear all files in the abc folder
FolderClean("abc", 0);
// File and related operation functions
// Move/copy the a.txt file under folder a to folder b and rename it to abc.txt
if(FileMove("a//a.txt", 0, " b//abc.txt", 0) == false){
Alert(GetLastError());
}
if(FileCopy("a//a.txt", 0, "b//abc.txt", 0) = = false){
Alert(GetLastError());
}
// Delete the file
FileDelete("text.csv");
if(FileIsExist() == true) {
Print("File exists");
} else {
Print("File Does not exist");
}
string fileName;
// "*" indicates the condition of searching for files, eg: if you want to search for files containing t, use "t*" to indicate
long fff = FileFindFirst("*", fileName, 0);
if(fff! = INVALID_HANDLE) {
// If there is another file in the current directory
while(FileFindNext(fff, fileName) == true) {
//
//
}
}
// File content operation function
// FILE_CSV: open csv file, FILE_SHARE_READ: multiple paths can access at the same time
int h = FileOpen("text.csv ", FILE_READ|FILE_WRITE|FILE_CSV|FILE_SHARE_READ,',', CP_ACP);
if(h != INVALID_HANDLE) {
// Write the file to the cache
FileWrite(h, Symbol(), High[0], Open[0 ], Low[0], Close[0]);
FileWrite(h, Symbol(), High[1], Open[1], Low[1], Close[1]); // Write to csv file The second line
// The array written must be a string array;
foo[0] = High[0];
foo[1] = Open[0];
foo[2] = Low[0];
foo[3] = Close[0];
FileWriteArray(h, foo, 0, WHOLE_ARRAY);
// Write the contents of the current cache to the file
FileFlush(h);
// You cannot use
string read immediately after the FileWrite function ;
ulong ft = 0;
while(FileIsEnding( h) == false) {
if(FileIsLineEnding(h) == true) {
Print(read);
read = "";
}
// Force the cursor to move to position 16 in the file
FileSeek(h, 16, SEEK_SET);
/ / Read the position of the cursor in the file
ft = FileTell(h);
read += FileReadString(h, 0);
ft = FileTell(h);
}
// When FileClose is called, the contents of the current cache will be written at once File
FileClose(h);
}
}
void OnStart() {
// Folder and related operation functions
FolderCreate("abc", 0);
FolderDelete("abc", 0);
// Clear all files in the abc folder
FolderClean("abc", 0);
// File and related operation functions
// Move/copy the a.txt file under folder a to folder b and rename it to abc.txt
if(FileMove("a//a.txt", 0, " b//abc.txt", 0) == false){
Alert(GetLastError());
}
if(FileCopy("a//a.txt", 0, "b//abc.txt", 0) = = false){
Alert(GetLastError());
}
// Delete the file
FileDelete("text.csv");
if(FileIsExist() == true) {
Print("File exists");
} else {
Print("File Does not exist");
}
string fileName;
// "*" indicates the condition of searching for files, eg: if you want to search for files containing t, use "t*" to indicate
long fff = FileFindFirst("*", fileName, 0);
if(fff! = INVALID_HANDLE) {
// If there is another file in the current directory
while(FileFindNext(fff, fileName) == true) {
//
//
}
}
// File content operation function
// FILE_CSV: open csv file, FILE_SHARE_READ: multiple paths can access at the same time
int h = FileOpen("text.csv ", FILE_READ|FILE_WRITE|FILE_CSV|FILE_SHARE_READ,',', CP_ACP);
if(h != INVALID_HANDLE) {
// Write the file to the cache
FileWrite(h, Symbol(), High[0], Open[0 ], Low[0], Close[0]);
FileWrite(h, Symbol(), High[1], Open[1], Low[1], Close[1]); // Write to csv file The second line
// The array written must be a string array;
foo[0] = High[0];
foo[1] = Open[0];
foo[2] = Low[0];
foo[3] = Close[0];
FileWriteArray(h, foo, 0, WHOLE_ARRAY);
// Write the contents of the current cache to the file
FileFlush(h);
// You cannot use
string read immediately after the FileWrite function ;
ulong ft = 0;
while(FileIsEnding( h) == false) {
if(FileIsLineEnding(h) == true) {
Print(read);
read = "";
}
// Force the cursor to move to position 16 in the file
FileSeek(h, 16, SEEK_SET);
/ / Read the position of the cursor in the file
ft = FileTell(h);
read += FileReadString(h, 0);
ft = FileTell(h);
}
// When FileClose is called, the contents of the current cache will be written at once File
FileClose(h);
}
}