EDN Admin
Well-known member
Hello,
I have the code to unzip the zip file to a folder from internet as below. Can anyone help me how to get the file name of each file in the folder? Thanks.
BSTR source = ::SysAllocString(zipFile); <br/>
BSTR dest = ::SysAllocString(unzipPath);<br/>
<span style="white-space
re <br/>
HRESULT hResult;<br/>
IShellDispatch *pISD;<br/>
Folder *pToFolder = NULL;<br/>
VARIANT vDir, vFile, vOpt;<br/>
<br/>
CoInitialize(NULL);<br/>
<br/>
hResult = CoCreateInstance(CLSID_Shell, NULL, CLSCTX_INPROC_SERVER, IID_IShellDispatch, (void **)&pISD);<br/>
<br/>
if (SUCCEEDED(hResult))<br/>
{<br/>
VariantInit(&vDir);<br/>
vDir.vt = VT_BSTR;<br/>
vDir.bstrVal = dest;<br/>
hResult = pISD->NameSpace(vDir, &pToFolder);<br/>
<br/>
if (SUCCEEDED(hResult))<br/>
{<br/>
Folder *pFromFolder = NULL;<br/>
<span style="white-space
re <br/>
<span style="white-space
re VariantInit(&vFile);<br/>
vFile.vt = VT_BSTR;<br/>
vFile.bstrVal = source;<br/>
<span style="white-space
re pISD->NameSpace(vFile, &pFromFolder);<br/>
<span style="white-space
re FolderItems *fi = NULL;<br/>
<span style="white-space
re pFromFolder->Items(&fi);<br/>
<span style="white-space
re long count=0;<br/>
<span style="white-space
re fi->get_Count(&count);<br/>
<span style="white-space
re <span style="white-space
re <br/>
VariantInit(&vOpt);<br/>
vOpt.vt = VT_I4;<br/>
vOpt.lVal = FOF_NO_UI;//4; // Do not display a progress dialog box<br/>
<br/>
<span style="white-space
re // Creating a new Variant with pointer to FolderItems to be copied<br/>
<span style="white-space
re VARIANT newV;<br/>
<span style="white-space
re VariantInit(&newV);<br/>
<span style="white-space
re newV.vt = VT_DISPATCH;<br/>
<span style="white-space
re newV.pdispVal = fi;<br/>
<span style="white-space
re hResult = pToFolder->CopyHere(newV, vOpt);<br/>
<span style="white-space
re pFromFolder->Release();<br/>
pToFolder->Release();<br/>
}<br/>
pISD->Release();<br/>
}<br/>
CoUninitialize();
View the full article
I have the code to unzip the zip file to a folder from internet as below. Can anyone help me how to get the file name of each file in the folder? Thanks.
BSTR source = ::SysAllocString(zipFile); <br/>
BSTR dest = ::SysAllocString(unzipPath);<br/>
<span style="white-space

HRESULT hResult;<br/>
IShellDispatch *pISD;<br/>
Folder *pToFolder = NULL;<br/>
VARIANT vDir, vFile, vOpt;<br/>
<br/>
CoInitialize(NULL);<br/>
<br/>
hResult = CoCreateInstance(CLSID_Shell, NULL, CLSCTX_INPROC_SERVER, IID_IShellDispatch, (void **)&pISD);<br/>
<br/>
if (SUCCEEDED(hResult))<br/>
{<br/>
VariantInit(&vDir);<br/>
vDir.vt = VT_BSTR;<br/>
vDir.bstrVal = dest;<br/>
hResult = pISD->NameSpace(vDir, &pToFolder);<br/>
<br/>
if (SUCCEEDED(hResult))<br/>
{<br/>
Folder *pFromFolder = NULL;<br/>
<span style="white-space

<span style="white-space

vFile.vt = VT_BSTR;<br/>
vFile.bstrVal = source;<br/>
<span style="white-space

<span style="white-space

<span style="white-space

<span style="white-space

<span style="white-space

<span style="white-space


VariantInit(&vOpt);<br/>
vOpt.vt = VT_I4;<br/>
vOpt.lVal = FOF_NO_UI;//4; // Do not display a progress dialog box<br/>
<br/>
<span style="white-space

<span style="white-space

<span style="white-space

<span style="white-space

<span style="white-space

<span style="white-space

<span style="white-space

pToFolder->Release();<br/>
}<br/>
pISD->Release();<br/>
}<br/>
CoUninitialize();
View the full article