+ Reply to Thread
Results 1 to 2 of 2

Thread: Getting File And Directory Owners

  1. #1
    Join Date
    Mar 2010
    Location
    Melbourne, Australia
    Posts
    17
    Blog Entries
    1
    Rep Power
    8

    Post Getting File And Directory Owners

    I have noticed not a lot of people know how to get the basic IO.file Owner information of a file/dir so i will show an example that you can play around with.


    'Required for The Directory Query.
    'Required for The NT User Account Query.

    Code:
    Imports System.IO
    Imports System.Security
    Imports System.Security.Principal

    Just Add this to a form, and add a reference to it in the form load events or a button event.
    Code:
    Public sub getowner()
              Try
                    Dim Target_Dir as string
                    Dim di As New DirectoryInfo(Target_Dir)
                    Dim ds As AccessControl.DirectorySecurity = di.GetAccessControl()
                    Dim owner As NTAccount = CType(ds.GetOwner(GetType(NTAccount)), NTAccount)
                    msgbox("File Owner: " & owner.ToString)
                Catch ex As Exception
                    msgbox("File Owner Error: " & ex.Message)
                End Try
    end sub
    Hope this helps anyone who is looking.

    Cheers

    -Sharper Software
    The Future Of Network Defense Systems, Today.

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Location
    Advertising world
    Posts
    Many

     
  3. #2
    Jarryd's Avatar
    Jarryd is offline Learning Programmer
    Join Date
    Sep 2010
    Location
    Queensland, Australia
    Posts
    63
    Rep Power
    6

    Re: Getting File And Directory Owners

    Nice work on this man,

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Largest directory and/or file
    By Wanch in forum Linux Tutorials, Guides and Tips
    Replies: 1
    Last Post: 10-12-2009, 12:10 AM
  2. Replies: 3
    Last Post: 03-30-2008, 06:05 PM
  3. Replies: 1
    Last Post: 01-01-2008, 02:27 PM
  4. Howto: Find the largest directory/file in a directory
    By ptt3 in forum Linux/Unix General
    Replies: 4
    Last Post: 05-28-2007, 02:08 PM

Tags for this Thread

Bookmarks

Posting Permissions

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