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();
        */
    
    }
    
    
  • 相关阅读:
    del命令
    echo命令
    什么是批处理
    ubuntu禁止ping操作(禁用ICMP协议访问)
    树莓派:raspberry pi 3b
    小tips合集
    吐个槽:bose的售后真心差劲!愧对这个顶级音响产品!
    WinSetupFromUSB
    win7 64位下vs不能以管理员身份运行的问题解决
    vs2010中如何设置Visual Assist方便地使用现成的代码编辑器风格
  • 原文地址:https://www.cnblogs.com/Fandyx/p/1886833.html
Copyright © 2011-2022 走看看