i know this question is asked 1000 times but I don't want to use any external tools like (DotNetZip or SharpZipLib).
I have currently this working piece of code:
string _from = Path.Combine(apk, "*.*") + '\0';
string _to = destination + '\0' + Path.Combine(destination, "*.*") + '\0';
NativeMethods.SHFILEOPSTRUCT fileop = new NativeMethods.SHFILEOPSTRUCT();
fileop.pFrom = _from;
fileop.pTo = _to;
fileop.wFunc = NativeMethods.FO_Type.FO_COPY;
fileop.fFlags = NativeMethods.FOF_Flag.FOF_WANTNUKEWARNING;
NativeMethods.SHFileOperation(ref fileop);
My problem is that I can't extract/copy a single file/folder. If i replace the *.*
for example with res\\drawable\\icon.png
it will do nothing.
Can someone tell me how to extract a single file/folder using the SHFILEOPSTRUCT
? Do I miss something?
The code supports:
Framework Version: .Net Client 4
OS: WinXP, 8, 8.1, 10
EDIT (Notice):
When you use this piece of code in an C# thread you'll always get an 'Path length exceeded' error... In this case you need to use an 'Dispatcher'.
SHFileOperation
is not capable of extracting individual items from a ZIP file. You options as I see them are:
ZipPackage
from System.IO.Packaging
has enough functionality to meet your needs.