473,856 Members | 1,568 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 3745
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
3330
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
2558
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
4666
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
2287
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
2340
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
1471
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
4279
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
5637
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
4466
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
9916
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
11057
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
10696
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...
1
10782
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9531
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7932
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
7094
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
4174
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3201
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.