// (c) 2006 Richard Grimes // www.grimes.demon.co.uk using System; using System.IO; using System.Reflection; using System.Security.Permissions; [assembly:AssemblyVersion("1.0.0.0")] [assembly:AssemblyKeyFile("key.snk")] public class LibraryCode { const string folder = @"C:\SecureFolder"; public static string GetData(string str) { // Code here is not subject to the permission demand // Determine the folder at runtime string strFolder = folder; FileIOPermission fio = new FileIOPermission( FileIOPermissionAccess.Read, strFolder); fio.Demand(); string strFile = folder + @"\" + str; StreamReader sr = new StreamReader(strFile); return sr.ReadToEnd(); } }