CommaIo.new Method [AX 2012]
Creates a new object of the CommaIo class.
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;
#define.ExampleFile(@"c:\test.txt")
#define.ExampleOpenMode("r")
perm = new FileIoPermission(#ExampleFile, #ExampleOpenMode);
if (perm == null)
{
return;
}
// Grants permission to execute the CommaIo.new method.
// CommaIo.new runs under code access security.
perm.assert();
io = new CommaIo(#ExampleFile, #ExampleOpenMode);
if (io != null)
{
con = io.read();
}
// Close the code access permission scope.
CodeAccessPermission::revertAssert();
}
Community Additions
ADD
Show: