473,394 Members | 1,781 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,394 software developers and data experts.

C# Programmatically Setting Permissions and Compressing a Folder (NTFS)

Hello,

I'm writing a C# windows form application and need some guidance on a couple
of issues.

First, my application needs to change the permissions on a folder. The
application creates a local group and I need to give that group Full Control
permissions to a folder on the file system. Would anyone know how to
accomplish this?

Next, my application also needs to programmatically set the properties of a
folder so that it's compressed. Would anyone know how to accomplish this?

Thanks!

Jul 11 '06 #1
2 3715
Maybe this help:
http://msdn2.microsoft.com/en-us/lib...on(d=ide).aspx

chanmm

"steggun" <no****@company.comwrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
Hello,

I'm writing a C# windows form application and need some guidance on a
couple
of issues.

First, my application needs to change the permissions on a folder. The
application creates a local group and I need to give that group Full
Control
permissions to a folder on the file system. Would anyone know how to
accomplish this?

Next, my application also needs to programmatically set the properties of
a
folder so that it's compressed. Would anyone know how to accomplish this?

Thanks!

Jul 12 '06 #2

"steggun" <no****@company.comwrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
| Hello,
|
| I'm writing a C# windows form application and need some guidance on a
couple
| of issues.
|
| First, my application needs to change the permissions on a folder. The
| application creates a local group and I need to give that group Full
Control
| permissions to a folder on the file system. Would anyone know how to
| accomplish this?
|
| Next, my application also needs to programmatically set the properties of
a
| folder so that it's compressed. Would anyone know how to accomplish this?
|
| Thanks!
|
|
|

When using V2 of the FCL you can use the FileSecurity class in the
System.Security.AccessControl namespace to change the access rights of a
filesystem object. The "compressed" FileAttribute of the DirectoryInfo class
can be used to set the compressed attribute of a folder. However, be aware
that you need to run as an administrator to be able to do this, which is a
bad idea, user applications should never run with administrative privileges.
Much better is to delegate this to an "administrative" application that
could be run as a COM+ server type application (check the
System.EnterpriseServices namespace), this application can run as
administrator while yours keep running with restricted privileges.

Willy.

Jul 12 '06 #3

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

Similar topics

0
by: John Dalberg | last post by:
How can I enable "list folder contents" ntfs permission only programmatically? The docs for cacls and xcalcs do not have an example to set this up without setting up the other read permissions. ...
7
by: Kim Lots | last post by:
Hi Sorry to disturb you again but i really like to know what's the NTFS folder permissions on a "virtual directory" folder for a public webserver iis 5.x running ASP 3.0 with an Access DB on a...
0
by: HitSkiper | last post by:
I am getting the error "The security ID structure is invalid." When running this code. Sub SetPermissions(ByRef vPath As String, ByVal UserName As String) Dim objADsSec As ADsSecurity Dim...
6
by: !!! Klutzo !!! | last post by:
I give permissions for ASPNET on a top level subdirectory. A windows program copies a file into the subdirectory, however, my web service cannot access the file because it does not have...
2
by: Ram | last post by:
Hey, I'v managed to find a way of adding NTFS permissions to a certain folder, But the problem is, the folder has a couple of inherited permissions which I want to delete. How can I remove the...
1
by: Codex Twin | last post by:
Hello folks Is it possible to add/remove Read Permissions (and any other NTFS permissions) to a folder programmatically via an ASP.NET page? Thanks.
4
by: Ram | last post by:
Hey, I'v managed to find a way of adding NTFS permissions to a certain folder, But the problem is, the folder has a couple of inherited permissions which I want to delete. How can I remove the...
1
by: James Beilby | last post by:
Hello people, It's been a long time since I've asked any techie questions on Usenet but I am under pressure to finish a project and the following issue has me stumped. I appreciate that it's a...
3
by: palepimp | last post by:
Hello all, I have searched far and wide for a solution to my issue. In short, here is the problem: 1. 3 PC's enter data into an Access 2003 database (PC's are running Vista w/ Office 2007...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.