mark FileIOPermissionAttribute
using System;
using System.IO;
using System.Security.Permissions;
[assembly:FileIOPermissionAttribute(SecurityAction.RequestMinimum, All=@"c:\\temp")]
public class MainClass
{
public static void Main()
{
FileStream fsOut = File.Create(@"c:\test.txt");
StreamWriter sw = new StreamWriter(fsOut);
sw.WriteLine("asdf.");
sw.Flush();
sw.Close();
}
}
Related examples in the same category