zoukankan      html  css  js  c++  java
  • Write and Read Text file usage to AX 2009

    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();
        */
    
    }
    
    
  • 相关阅读:
    hdu 6702 ^&^ 位运算
    hdu 6709 Fishing Master 贪心
    hdu 6704 K-th occurrence 二分 ST表 后缀数组 主席树
    hdu 1423 Greatest Common Increasing Subsequence 最长公共上升子序列 LCIS
    hdu 5909 Tree Cutting FWT
    luogu P1588 丢失的牛 宽搜
    luogu P1003 铺地毯
    luogu P1104 生日
    luogu P1094 纪念品分组
    luogu P1093 奖学金
  • 原文地址:https://www.cnblogs.com/Fandyx/p/1886833.html
Copyright © 2011-2022 走看看