static void Jimmy_FileTextIoWriteRead(Args _args) { TextIo txIoRead,txIoWrite; FileIOPermission fioPermission; container ConData; int xx,LenData; str sTempPath, sFileName = "Test_File_IO.txt", sOneRecord;; sTempPath = WINAPI::getTempPath();// Get the temporary path.//info("File is at: " + sTempPath + sFileName); // Assert permission. fioPermission = new FileIOPermission(sTempPath + sFileName ,"RW"); fioPermission.assert(); // If the test file already exists, delete it. if (WINAPI::fileExists(sFileName)) WINAPI::deleteFile(sTempPath + sFileName); // Open a test file for writing. // "W" mode overwrites existing content, or creates the file. txIoWrite = new TextIo( sTempPath + sFileName ,"W"); // Write records to the file. txIoWrite.write("Start....."); txIoWrite.write("Everybody good evening, my name is Xie YuFan and English name is Jimmy, I am come from China, I am a ERP software engineer. I enjoy my work very much!"); txIoWrite.write("I hope here to realize more friends around the world."); txIoWrite.write("My blog is : http://www.cnblogs.com/Jimmyx/"); txIoWrite.write("QQ : 332469390"); txIoWrite.write("end....."); /***********************************************************/ txIoRead = null;// Close the test file. txIoRead = new TextIo(sTempPath + sFileName ,"R");// Open the same file for reading. ConData = txIoRead.read(); // Read the entire file into a container. while (ConData) // Loop through the container of file records. { sOneRecord = ""; LenData = conLen(ConData); for (xx=1; xx <= LenData; xx++) // Loop through the token in the current record. { if (xx > 1) sOneRecord += " "; sOneRecord += conPeek(ConData ,xx); } info(sOneRecord); ConData = txIoRead.read();// Read the next record from the container. } txIoRead = null; // Close the test file. WINAPI::copyFile(sTempPath + sFileName,@"c:\\" +sFileName,true); /* if(WINAPI::fileExists(sTempPath + sFileName)) // Delete the test file. WINAPI::deleteFile(sTempPath + sFileName); revertAssert is not really necessary here, because the job (or method) is ending. CodeAccessPermission::revertAssert(); */ }