AsciiIo.new Method [AX 2012]

Creates an instance of the AsciiIo class.

public void new(str filename, str mode)

Run On

Called

Parameters

filename
Type: str
The name of the file to open for this instance of the AsciiIo class.
mode
Type: str
The mode to use to create this instance of the AsciiIo class.

If an attacker can control input to the new method, a security risk exists. Therefore, this method runs under Code Access Security. Calls to this method on the server require permission from the FileIOPermission class. Make sure that the user has development privileges by setting the security key to SysDevelopment on the control that calls this method.

The following example uses the AsciiIo class to read from a text file.

void AsciiIoExample() 
{ 
    AsciiIo asciiIo; 
    container con; 
    FileIoPermission perm; 
  
    #define.ExampleFile(@"c:\test.txt") 
    #define.ExampleOpenMode("r") 
     
    // The AsciiIo.new method runs under code access permission. 
    perm = new FileIoPermission(#ExampleFile, #ExampleOpenMode); 
    if (perm == null) 
    { 
        return; 
    } 
  
    // Code access permission scope starts here. 
     perm.assert(); 
  
     asciiIo = new AsciiIo(#ExampleFile, #ExampleOpenMode); 
    if (asciiIo != null) 
    { 
          con = asciiIo.read(); 
    } 
    // Closes the code access permission scope. 
    CodeAccessPermission::revertAssert(); 
}

Community Additions

ADD
Show: