Creates a new object of the CommaIo class.


public void new(str filename, str mode)

Run On



  • filename
    Type: str
    The name of the file to open.
  • mode
    Type: str
    The mode that the file should be opened in. Specify the mode as follows:


A run-time error occurs if the file is accessed by using a method that does not correspond to the current mode. For example, an error occurs if a user tries to write to a file that is opened in read mode.

If an attacker can control input to this 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 a CommaIO object to read from the ExampleFile file.

    CommaIo         io; 
    container       con; 
    FileIoPermission perm; 
    perm = new FileIoPermission(#ExampleFile, #ExampleOpenMode); 
    if (perm == null) 
    // Grants permission to execute the method. 
    // runs under code access security. 
    io = new CommaIo(#ExampleFile, #ExampleOpenMode); 
    if (io != null) 
        con =; 
    // Close the code access permission scope. 

See Also


CommaIo Class