Re: File.Exists question

From: Dennis Myrén (dennis_at_oslokb.no)
Date: 09/10/04


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");
> > >
> > >
> >
> >
>
>


Relevant Pages

  • Re: Security Problem With Windows 2003
    ... denying some of those rights and causing the app to crash. ... MSCE,MSCA,CISSP, Security + ... | X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 ... I have a Windows ...
    (microsoft.public.windows.server.security)
  • Re: Secure shared web hosting using MAC Framework
    ... run the web server and web users shell in a jail, ... Those rights should have priority on any traditional unix file ... This directive allows you to disable certain functions for security reasons. ... Web users and executed web scripts shouldn't be able to read ...
    (FreeBSD-Security)
  • Orwell meets Kafka
    ... THE OTHER DAY, the new secretary of homeland security, Michael Chertoff, scrapped the moronic rule requiring everyone to stay seated for 30 minutes coming in or out of Ronald Reagan Washington National Airport. ... If the American republic was built on any core principle, that principle is the rights of people to be free from the abuses of unchecked power. ...
    (soc.culture.australian)
  • RE: Rights
    ... the benefit is improved security. ... in restricting rights in favor of increased security. ... EARN A MASTER OF SCIENCE IN INFORMATION ASSURANCE - ONLINE ... The NSA has designated Norwich University a center of Academic ...
    (Security-Basics)
  • Re: WordPerfect
    ... could add Domain Users to the Power User group on each computer and this ... Win 2k's security is tightened down considerably more that Win NT ... >> and had profiles for other users to use the same icon to access WP8 and ... So we know it is a rights thing of some sort. ...
    (microsoft.public.win2000.security)