I expected this code:
if (!File.Exists(fullFileName))
{
File.Create(fullFileName);
}
File.SetAttributes(fullFileName, FileAttributes.Compressed);
To set this flag:
But it doesn't... What am I doing wrong? How do I set that flag on a file?
UPDATE: It says in the documentation
"It is not possible to change the compression status of a File object using the SetAttributes method."
And apparently it doesn't work when using the static File.SetAttributes either.
Given that, how can this be achieved?
The attributes are a bitmask.
Try this:
(Found in File.SetAttributes Method under
Examples
.)