Compress a folder using NTFS compression in .NET

前端 未结 6 1238
Happy的楠姐
Happy的楠姐 2021-02-01 09:48

I want to compress a folder using NTFS compression in .NET. I found this post, but it does not work. It throws an exception (\"Invalid Parameter\").

DirectoryI         


        
6条回答
  •  花落未央
    2021-02-01 10:17

    I don't believe there is a way to set folder compression in the .NET framework as the docs (remarks section) claim it cannot be done through File.SetAttributes. This seems to be only available in the Win32 API using the DeviceIoControl function. One can still do this through .NET by using PInvoke.

    Once familiar with PInvoke in general, check out the reference at pinvoke.net that discusses what the signature needs to look like in order to make this happen.

提交回复
热议问题