get file name from the list of file

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
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:pre <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:pre <br/>
<span style="white-space:pre VariantInit(&vFile);<br/>
vFile.vt = VT_BSTR;<br/>
vFile.bstrVal = source;<br/>
<span style="white-space:pre pISD->NameSpace(vFile, &pFromFolder);<br/>
<span style="white-space:pre FolderItems *fi = NULL;<br/>
<span style="white-space:pre pFromFolder->Items(&fi);<br/>
<span style="white-space:pre long count=0;<br/>
<span style="white-space:pre fi->get_Count(&count);<br/>
<span style="white-space:pre <span style="white-space:pre <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:pre // Creating a new Variant with pointer to FolderItems to be copied<br/>
<span style="white-space:pre VARIANT newV;<br/>
<span style="white-space:pre VariantInit(&newV);<br/>
<span style="white-space:pre newV.vt = VT_DISPATCH;<br/>
<span style="white-space:pre newV.pdispVal = fi;<br/>
<span style="white-space:pre hResult = pToFolder->CopyHere(newV, vOpt);<br/>
<span style="white-space:pre pFromFolder->Release();<br/>
pToFolder->Release();<br/>
}<br/>
pISD->Release();<br/>
}<br/>
CoUninitialize();

View the full article
 
Back
Top