Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / Win API / November 2007



Tip: Looking for answers? Try searching our database.

Minimum permission to compress files and folders

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Andy Smith - 14 Nov 2007 22:12 GMT
I have some code which compresses a whole folder structure, and it works OK,
but I have admin privileges.  For someone who doesn't, my code fails --
however they can successfully right-click a folder, choose Properties, and
use the Advanced button to compress its whole structure and all contents.  So
the problem is, I'm asking for too much permission in my code.

Here's the essence of my VB code:

Sub Compress(sFileOrFolder as String)
   Dim lFileHwnd As Long, lBytesRtn As Long, iOutput As Integer, lResult as
Long

   lFileHwnd = CreateFile(sFileOrFolder, GENERIC_ALL, 0&, 0&,
OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0&)

   lResult = DeviceIoControl(lFileHwnd, FSCTL_SET_COMPRESSION,
COMPRESSION_FORMAT_DEFAULT, 2&, iOutput, 2&, lBytesRtn, 0&)

End Sub

I've found other code out there with many different settings for the
parameters to CreateFile, even one with dwDesiredAccess (#2) set to only
GENERIC_READ, but none mentioning FILE_WRITE_EA or FILE_WRITE_ATTRIBUTES,
which seems to make sense.  Also, it seems to me there should be no sharing
during compression, but I see code with dwShareMode (#3) set to SHARE_ALL,
etc., all over.

What's the bare minimum access and sharing I really need to compress files
and folders?  Thanks.

Signature

Andy Smith
Senior Systems Analyst
Standard and Poor''s, NYC

Anand.V.V.N - 30 Nov 2007 15:20 GMT
Hello,
Not sure if this makes sense, I think the bare minimum permission would that
you have to be the creator of the folder/files, another thing would be that
you have to have read and write permission on the folder/file I think
Anand
Signature

"Who will guard the guards?"

> I have some code which compresses a whole folder structure, and it works OK,
> but I have admin privileges.  For someone who doesn't, my code fails --
[quoted text clipped - 25 lines]
> What's the bare minimum access and sharing I really need to compress files
> and folders?  Thanks.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.