473,395 Members | 1,403 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

How to get file owner information

I use the below codes downloaded from
http://www.visualbasicforum.com/showthread.php?t=158264 to perform a
recursive search of files and folders. I can obtain most of the information
such as the filename, last modified, last accessed, last created but I'm not
able to get the "owner" information which is the most important info that I
need to get.

I want to know who "creates" this file. By the way I use VB.NET languages
with VS.NET IDE.

Can someone enlighthen me or direct me to some sample page on how the codes
to get file information (security?)

Thanks

Carlos.

----------------------------------------------------------------

Private Overloads Function Recursive(ByVal strPath As String)

Dim oDir As New System.IO.DirectoryInfo(strPath)
Dim oSubDir() As System.IO.DirectoryInfo
Dim oFiles() As System.IO.FileInfo
Dim i As Int32

oFiles = oDir.GetFiles
For i = 0 To oFiles.Length - 1
Debug.WriteLine(oFiles(i).Name.ToString)
Next
oSubDir = oDir.GetDirectories()
For i = 0 To oSubDir.Length - 1
Debug.WriteLine(oSubDir(i).Name.ToString)
'more code to do whatever here

Call Recursive(oSubDir(i), 1)
Next

End Function

Private Overloads Function Recursive(ByVal oDir As System.IO.DirectoryInfo,
ByVal intLevel As Int32)

Dim oSubDir() As System.IO.DirectoryInfo
Dim oFiles() As System.IO.FileInfo
Dim i As Int32

oFiles = oDir.GetFiles
For i = 0 To oFiles.Length - 1
Debug.WriteLine(New String(" ", intLevel) & ">" &
oFiles(i).Name.ToString)
Next

oSubDir = oDir.GetDirectories()
For i = 0 To oSubDir.Length - 1
Debug.WriteLine(New String(" ", intLevel) &
oSubDir(i).Name.ToString)
'more code to do whatever here

Call Recursive(oSubDir(i), intLevel + 1)
Next

End Function

Nov 20 '05 #1
1 11189
"Carlos" <wt*****@hotmail.com> skrev i meddelandet
news:uz**************@tk2msftngp13.phx.gbl...
I use the below codes downloaded from
http://www.visualbasicforum.com/showthread.php?t=158264 to perform a
recursive search of files and folders. I can obtain most of the information such as the filename, last modified, last accessed, last created but I'm not able to get the "owner" information which is the most important info that I need to get.

I want to know who "creates" this file. By the way I use VB.NET languages
with VS.NET IDE.

Can someone enlighthen me or direct me to some sample page on how the codes to get file information (security?)

Call GetNamedSecurityInfo asking for OWNER_SECURITY_INFORMATION and you'll
get the owner's SID. Then call LookupAccountSID to get the account name.

Or use WMI. The GetSecurityDescriptor method of the
LogicalFileSecuritySetting class retrieves a SecurityDescriptor object. One
of the properties of that object is the owner (name, domain etc).

WMI should be the most straightforward method since it's part of the
framework (if I recall correctly).

Unfortinately, since you're using VB.NET I'm unable to provide any example
code. This group is for "classic" VB only (version 6 and below).

--
Björn Holmgren
Guide Konsult AB
Nov 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Angelos | last post by:
Hello.. I am trying to make a filesystem management script. I want to display a list of files and directories and be able to delete them from this list.... I made a search on the net and there are...
10
by: Steve | last post by:
Hi all i am just starting to get back into VB and i need a little help. I am writing a program that asks a user to type in a set of numbers/letters (in this case shipping containers). Once the...
7
by: Shane | last post by:
Hi, Thanks in advance for the help. I have been to many websites and tried several solutions to my problem, but have fixed part of it. It's time to come humbly to the newsgroups for help :-) ...
1
by: ROS38 | last post by:
I have an access 97 (I know, it's old, they won't let me upgrade, don't ask) databse that many of the people in my company use pretty constantly. Using it with access produces no errors ever....
2
by: John Regan | last post by:
Hello All I am trying to find the owner of a file or folder on our network (Windows 2000 Server) using VB.Net and/or API. so I can search for Folders that don't follow our company's specified...
1
by: laredotornado | last post by:
Hi, I'm using PHP 4.4.4 on Apache 2 on Fedora Core 5. PHP was installed using Apache's apxs and the php library was installed to /usr/local/php. However, when I set my "error_reporting"...
5
by: MLH | last post by:
Searching at http://support.microsoft.com/search/?adv=0 for Access 97 and "templatefile" returns the following: There are no documents that match your search for "templatefile" Has anyone ever...
6
by: kai rosenthal | last post by:
Hello, with ls -l on windows I get -rw-r--r-- 1 500 everyone 320 Nov 09 09:35 myfile How can I get on windows with a standard python 2.2 (without windows extensions) the information "500" and...
2
by: levimc | last post by:
I know that that topic may be old to you but I looked at other more- than-two-year-old topics related to mine. However, I didn't find them working for my project at all because its errors return...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.