Re: File.Exists question
From: Dennis Myrén (dennis_at_oslokb.no)
Date: 09/10/04
- Next message: Ciaran: "What is equivalen converting C -> C#"
- Previous message: James Johnson: "Re: Extracting String Info from WebRequest Cookie"
- In reply to: Dan: "Re: File.Exists question"
- Next in thread: Willy Denoyette [MVP]: "Re: File.Exists question"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 10 Sep 2004 16:13:44 +0200
Are you completely sure the file name is correct?
--
Regards,
Dennis JD Myrén
Oslo Kodebureau
"Dan" <dan@dontspamme.com> wrote in message
news:%23qNps$zlEHA.1652@TK2MSFTNGP09.phx.gbl...
> But I'm running with administrative rights, with full access to the files
in
> that directory. Could it have something to do with running from the
> debugger?
>
> "Willy Denoyette [MVP]" <willy.denoyette@pandora.be> wrote in message
> news:OWroB6zlEHA.2864@TK2MSFTNGP14.phx.gbl...
> > If you (the windows identity running the code) don't have the right
> > permissions to the folder holding the file, File.Exists will return
false,
> > as you are experiencing.
> > This is called "windows access security " based on the identity of the
> > caller.
> > You are confusing this security mechanism with .NET's "Code access
> security"
> > , this kind of security mechanism is based on the "code identity" (where
> did
> > the code came from - internet, intranet, codegroup , ...) NOT the
windows
> > user identity, these are fundamentally different. Whatever you do in
code
> > (that is Code Access Security) won't help if the "windows user" has no
> > access rights for the objects (like files) controlled by the OS security
> > system (Windows security).
> >
> > In short you need to fix the NTFS security settings on the file/folder.
> >
> > Willy.
> >
> >
> >
> > "Dan" <dan@dontspamme.com> wrote in message
> > news:OsLAPhzlEHA.3452@TK2MSFTNGP15.phx.gbl...
> > >I have code like the following to test for existence of a file. I know
> the
> > > file is there, but File.Exists returns FALSE. The problem appears to
be
> > > that the file is in a directory beneath "My Documents". When I move
it
> to
> > > a
> > > directory directly under the root, File.Exists returns TRUE. So I
tried
> > > using FileIOPermission to give me rights to read it, but still no
luck.
> > > Any
> > > suggestions? Thanks...
> > >
> > > FileIOPermission f = new
> > > FileIOPermission(FileIOPermissionAccess.AllAccess, fileName);
> > > if (!File.Exists(fileName))
> > > throw new FileNotFoundException("Unable to construct
> > > BinaryUploadFile object. File does not exist:\n\n" + fileName +
"\n\n");
> > >
> > >
> >
> >
>
>
- Next message: Ciaran: "What is equivalen converting C -> C#"
- Previous message: James Johnson: "Re: Extracting String Info from WebRequest Cookie"
- In reply to: Dan: "Re: File.Exists question"
- Next in thread: Willy Denoyette [MVP]: "Re: File.Exists question"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|