Share via


AsciiIo.newmethod(String, String) Method

Definition

Creates an instance of the AsciiIo class.

public:
 override void newmethod(System::String ^ _filename, System::String ^ _mode);
public override void newmethod (string _filename, string _mode);
override this.newmethod : string * string -> unit
Public Overrides Sub newmethod (_filename As String, _mode As String)

Parameters

_filename
String

The mode to use to create this instance of the AsciiIo class.

_mode
String

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.

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

Applies to