473,769 Members | 5,415 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

C# Programmaticall y 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 programmaticall y set the properties of a
folder so that it's compressed. Would anyone know how to accomplish this?

Thanks!

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

chanmm

"steggun" <no****@company .comwrote in message
news:%2******** ********@TK2MSF TNGP05.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 programmaticall y 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******** ********@TK2MSF TNGP05.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 programmaticall y 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.Enterpri seServices 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
3319
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. John Dalberg
7
2553
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 w2k pro machine with anonymous access. Fyg this is non commercial website for neighbour members in a carpool with booking possibility. No file upload is allowed/possible/needed. Login is manged by the ASP script
0
4665
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 objSecDes As SecurityDescriptor Dim objDAcl As AccessControlList Dim objAce As Object Dim objAce1 As AccessControlEntry Dim objAce2 As AccessControlEntry
6
2283
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 permissions. Shouldn't the file automatically inherit permissions by being dropped into that top level subdirectory?
2
2336
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 folder's NTFS permissions WITHOUT using WMI or special XP features? Thanks ahead! --Ram
1
1465
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
4273
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 folder's NTFS permissions WITHOUT using WMI or special XP features? Thanks ahead! --Ram
1
5634
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 bit long-winded but I'd be much obliged if anyone could shed any light... I am currently developing a PHP-based site for a client on IIS. It might be worth pointing out here that, from a Linux background, I am no expert on IIS or NTFS...
3
4461
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 pro). The database has been used for a long time and we haven't upgraded it to a 2007 version database. 2. One of the PC's hosts the "master" database, the 2 others are using Replica's of "master" database. At the end of each work day, the...
0
9579
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10197
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10032
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9848
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7391
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5293
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5432
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3947
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2810
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.