March 2004
Intermediate to advanced
560 pages
26h 47m
English
using System;
using System.IO;
using System.Security.Permissions;
namespace Samples
{
public class UnauthorizedAccessExceptionConstructor
{
public static void Main()
{
try
{
string s = "readonly.txt";
FileStream fs = File.OpenWrite(s);
}
catch(UnauthorizedAccessException e)
{
Console.WriteLine("Exception: {0}", e);
}
}
}
}
Exception: System.UnauthorizedAccessException: Access to the path "C:\Books\BCL\Samples\System\UnauthorizedAccessException\readonly.txt" is denied. at System.IO.__Error.WinIOError(Int32 errorCode, String str) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean useAsync, String msgPath, Boolean bFromProxy) at System.IO.FileStream..ctor(String ...
Read now
Unlock full access