AsciiIo.new Method

Creates an instance of the AsciiIo class.

Syntax

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.

Remarks

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.

Examples

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(); 
}

See Also

Reference

AsciiIo Class