| re: System.IO.File.Exists behaves differently when run from a mapped drive
It seems File.Exists doesn't make a difference between a File Existing and
having permissions to run the assembly from the network with the improper
security policies.
"Zeno Lee" <zeno_lee@hotmail.com> wrote in message
news:u9Of17w$EHA.2568@TK2MSFTNGP10.phx.gbl...[color=blue]
> I'm using File.Exists to test a file on my C: drive.
> My program was strongly named and had caspol -af run on it to allow it to
> run from the network.
>
> There are 3 ways I am doing this:
>
> 1) Run from my C: drive, File.Exists works properly and says
> C:\Temp\test.txt exists
> 2) Run from my H:\ (network) drive, File.Exists says the file doesn't
> exist.
> 3) Run from Visual Studio debugger, with project configuration property
> working directory set to H:\, File.Exists works properly
>
> What is going on? Does a strongly named exe with caspol run on it behave
> differently?
>
>
> Here's the code below.
>
>
> [STAThread]
> static void Main(string[] args)
> {
> string _cvs = @"C:\Temp\test.txt";
> Console.WriteLine("Current Directory: " +
> Directory.GetCurrentDirectory());
> if (File.Exists(_cvs))
> {
> Console.WriteLine(_cvs + " exists.");
> }
> else
> {
> Console.WriteLine(_cvs + " doesn't exist.");
> }
> Console.ReadLine();
> }
>
>[/color] |