Digg StumbleUpon LinkedIn YouTube Flickr Facebook Twitter RSS Reset

Exemple d’utilisation de ‘PermissionSet’

Exemple,d'utilisation,de,'PermissionSet'
{filelink=17848}

using System;
using System.Security;
using System.IO;
using System.Security.Permissions;
 
public class MainClass
{
    public static void Main()
	{
        PermissionSet permission = new PermissionSet(System.Security.Permissions.PermissionState.None);
 
        permission.AddPermission(new FileIOPermission(FileIOPermissionAccess.Read | FileIOPermissionAccess.Write | FileIOPermissionAccess.Append, @"c:mesexemplesteste.txt"));
 
       permission.Assert();
 
        FileStream fs = new FileStream(@"c:mesexemplesteste.txt",FileMode.OpenOrCreate, FileAccess.Write);
        StreamWriter m_streamWriter = new StreamWriter(fs);
 
        m_streamWriter.BaseStream.Seek(0, SeekOrigin.End);
        m_streamWriter.Write("Bienvenu sur csharp.mesexemples.com");
    }
}

No comments yet.

Leave a Comment