473,326 Members | 2,095 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,326 software developers and data experts.

How to programmatically set the "compress" attribute of a folder with C#

Anybody?

thanks,
Sean

Nov 16 '05 #1
3 2623

You can call DeviceIoControl(FSCTL_SET_COMPRESSION) via PInvoke.

http://msdn.microsoft.com/library/en...eiocontrol.asp
http://msdn.microsoft.com/library/en...ompression.asp

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 16 '05 #2

<de*****************@yahoo.com> wrote in message
news:11*********************@f14g2000cwb.googlegro ups.com...
Anybody?

thanks,
Sean


Very easy, use System.Management and WMI's class Win32_Directory method
Compress.
Here's a sample....

using System.Management;
....
string dirName = "c:\\\\somefolder";
string objPath = "Win32_Directory.Name=" + "\"" + dirName + "\"";
Console.WriteLine(objPath);
using (ManagementObject dir= new ManagementObject(objPath))
{
ManagementBaseObject outParams = dir.InvokeMethod("Compress", null,
null);
uint ret = (uint)(outParams.Properties["ReturnValue"].Value);
if(ret == 0)
Console.WriteLine("Success");
else Console.WriteLine("Failed with error code: {0}", ret);
}

Willy.
Nov 16 '05 #3
Many thanks gentlemen

Sean

Nov 16 '05 #4

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

Similar topics

3
by: John Reese | last post by:
Mozilla, Firefox, Thunderbird, and so forth use this awful format called MORK to store all kinds of things: which messages you've read in a newsgroup, headers and indexes into the mbox file of...
5
by: apple | last post by:
UDBV8 fp 6a - AIX 5.1 We have scheduled cron jobs to do backups. Periodically and starting to occur more frequently, a backup fails with this error: SQL2072N Unable to bind the shared library...
3
by: Hon Yuen, Ng | last post by:
Hi I have a dataset that stores quite a lot of data from database and I need to transfer this over network with slow connection. May i know is it possible to "compress" the dataset in whatever...
3
by: shearichard | last post by:
Hi - Feeling a bit weird about this but I cannot find the 'begin' method on a connection object of MySQLdb. Can anyone explain why ? I'm using version 1.2.0 which is pretty recent and I've read...
0
by: itzel | last post by:
Hello!! In using tarfile to group thousands of small files from a directory and then compress it. I already compress a group of files in my pc, but I need do it in a server and I'm testing the...
3
by: Benny Ng | last post by:
Dear All, Now I met some performance problems in my application. Because according to our business. The size of some web forms are larger than 1xxx MB. So it takes a long time for user opening a...
26
by: Don Calloway | last post by:
I have created a <filename>.db1 (where <filenameis the name given to the database) Access database that is being used in multi-user mode. When the <filename>.db1 file is opened by a user, the...
6
by: Eternal | last post by:
Hello All, I am trying to compress a folder with different kinds of files and sub-folder programmatically. Googleing all the c# forums and news groups (almost for half a day ) lead me to...
3
by: bollweevil | last post by:
Hello Everyone, I do Django web development on my Mac at home, and then I rsync the files with the Ubuntu web server. I want to write one single bash shell script that rsyncs the files and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.