class CreateAndSaveTextFile
{
/// <summary>
/// Create and Save the text file in specific local directory.
/// </summary>
/// <param name = "_args">The specified arguments.</param>
public static void main(Args _args)
{
CreateAndSaveTextFile createAndSaveTextFile= new CreateAndSaveTextFile ();
createAndSaveTextFile.generateFile();
}
private void generateFile()
{
System.IO.StreamWriter sw;
InteropPermission perm = new InteropPermission(InteropKind::ClrInterop);
try
{
perm.assert();
sw = new System.IO.StreamWriter(@"C:\test.txt"); // specify the local file path for new file.
sw.WriteLine('line 1');
sw.WriteLine('line2');
sw.Dispose();
CodeAccessPermission::revertAssert();
}
catch
{
error("Error");
}
}
}
{
/// <summary>
/// Create and Save the text file in specific local directory.
/// </summary>
/// <param name = "_args">The specified arguments.</param>
public static void main(Args _args)
{
CreateAndSaveTextFile createAndSaveTextFile= new CreateAndSaveTextFile ();
createAndSaveTextFile.generateFile();
}
private void generateFile()
{
System.IO.StreamWriter sw;
InteropPermission perm = new InteropPermission(InteropKind::ClrInterop);
try
{
perm.assert();
sw = new System.IO.StreamWriter(@"C:\test.txt"); // specify the local file path for new file.
sw.WriteLine('line 1');
sw.WriteLine('line2');
sw.Dispose();
CodeAccessPermission::revertAssert();
}
catch
{
error("Error");
}
}
}
No comments:
Post a Comment