将文件解压缩到我指定的目录中 [英] Unzip a file into a directory I specified

查看:133
本文介绍了将文件解压缩到我指定的目录中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我尝试过的,但它不起作用:



 ZRESULT TUnzip :: Open( void  * z, unsigned   int  len,DWORD flags)
{
if (uf!= 0 || currentfile!= - 1
return ZR_NOTINITED;

GetCurrentDirectory(MAX_PATH,rootdir);
_tcscat(rootdir,_T( \\ temp)); // 添加临时目录,但无法正常工作
_tcscat(rootdir,_T( \\);

if (flags == ZIP_HANDLE)
{
DWORD type = GetFileType(z);
if ( type!= FILE_TYPE_DISK)
return ZR_SEEK;
}
ZRESULT e;
LUFILE * f = lufopen(z, len,flags,& e);
if (f == NULL)
return e;
uf = unzOpenInternal(f);
// 返回ZR_OK;
return zopenerror; // +++ 1.2
}

解决方案

你需要指定一个完整的路径。



GetFolderPath 你得到了正确的。



请记住:出于安全原因你不能到处写...


This is what I tried, but it is not working:

ZRESULT TUnzip::Open(void *z,unsigned int len,DWORD flags)
{
    if (uf!=0 || currentfile!=-1) 
        return ZR_NOTINITED;

    GetCurrentDirectory(MAX_PATH,rootdir);
    _tcscat(rootdir,_T("\\temp")); //add temp dir, but can not work 
    _tcscat(rootdir,_T("\\");

    if (flags==ZIP_HANDLE)
    { 
        DWORD type = GetFileType(z);
        if (type!=FILE_TYPE_DISK) 
            return ZR_SEEK;
    }
    ZRESULT e; 
    LUFILE *f = lufopen(z,len,flags,&e);
    if (f==NULL) 
        return e;
    uf = unzOpenInternal(f);
    //return ZR_OK;
    return zopenerror; //+++1.2
}

解决方案

you need to specify a full path.

With GetFolderPath you get the right one.

Remember: you cant write everywhere for security reasons...


这篇关于将文件解压缩到我指定的目录中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆