Results 1 to 3 of 3

Thread: File Permissions in VB2008

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Oct 2008
    Location
    Midwest Region, United States
    Posts
    3,574

    File Permissions in VB2008

    Hi,

    I'm trying to put together a simple "file search" app that lets the user specify where to look, what type of files to look for, what the minimum file size is, etc. (I know...sounds kinda like capabilities that already exist in Windows!). I'm running into "access" issues, even with directories that I wouldn't think I should have any trouble accessing.

    I'm doing something like this:

    Dim f As New FileIOPermission(PermissionState.Unrestricted)
    f.AllLocalFiles = FileIOPermissionAccess.Read
    Try
    f.Demand()
    Catch s As SecurityException
    Console.WriteLine(s.Message)
    End Try

    All I want to do is get the file attributes (size, location, name, date modified, etc.). I don't want/need write access.

    Any suggestions? Thanks!

    Bryce

  2. #2
    Frenzied Member MaximilianMayrhofer's Avatar
    Join Date
    Aug 2007
    Location
    IM IN YR LOOP
    Posts
    2,001

    Re: File Permissions in VB2008

    Are you running this on Vista? If you're running it from Visual Studio, you'll have to close VS and then select 'run as administrator'. This will solve quite a few problems. But not all.

    There are 4 integrity levels in vista: low, medium, high and system. As an administrator, you operate by default at the low level, but can choose to elevate yourself and processes all the way up to 'high' should you require it. Unfortunately, there is still one level higher, which is 'system'.

    The problem you are going to have is that this 'system' level (who is also a 'user' in vista) owns a bunch of files and folders on the OS. And even when you elevate your security level as an administrator, you still fall short of this mark.

    You may want to take a look at this article for developing in vista. It does mention the ability to create a system access token, but I didn't read fully.
    Last edited by MaximilianMayrhofer; Jan 15th, 2009 at 12:37 PM.

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Oct 2008
    Location
    Midwest Region, United States
    Posts
    3,574

    Re: File Permissions in VB2008

    Max,

    I've had the issue both in XP and in Vista.

    I'll check out the link you provided, though.

    Thanks!

    Bryce

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width