资讯   |   开发   |   选机中心   |   产品大全 | IBM | 惠普 | 联想 | 戴尔 | 苹果 | 神舟
更多: | 华硕 | 明基 | 方正 | 紫光 | TCL | 夏新 | 联宝 | 宏碁 | 七喜 | 长城 | 清华同方 | 海尔 | 三星 | 东芝 | 索尼 | 富士通 | LG | 技术 | ddnoon
当前位置:笔记本 > 软件开发 >
Advertisement
文章正文

判断是否存在 某文件, 用什么函数?包含什么头文件?? 还有 直接拷贝文件的。

类型:转载   责任编辑:asp.net   日期:2007/05/23


热门软件下载:


   

如题

网友回答:

发表者:happyparrot

DWORD   GetFileAttributes(  
      LPCTSTR   lpFileName       //   name   of   file   or   directory  
  );  
  如果返回-1,则表示文件或者目录不存在

发表者:he_zhidan

int   IsDirectoryOrFile(CString   strFileName)  
  {  
  strFileName.TrimLeft();  
  strFileName.TrimRight();  
   
  WIN32_FIND_DATA   fd;  
  HANDLE   hFind   =   ::FindFirstFile(strFileName,&fd);  
  ::FindClose(hFind);  
   
  //不存在同名的文件或文件夹  
  if   (hFind   ==   INVALID_HANDLE_VALUE)  
  {  
  return   0   ;  
  }  
  //判断是否为目录  
  else   if   (fd.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY)  
  {  
  return   2   ;  
  }  
  else  
  {  
  return   1;  
  }  
  }

发表者:camelyi

文件是否存在:  
  BOOL   IsFileValid(const   CString&   strFilePath)  
  {  
  DWORD   dwAttribs   =   GetFileAttributes(strFilePath);  
  if   (dwAttribs   ==   ((DWORD)-1))  
  {  
  return   FALSE;  
  }  
  else  
  {  
  return   ((!(dwAttribs   &   FILE_ATTRIBUTE_DIRECTORY))   ?   TRUE   :   FALSE);  
  }  
  }  
   
  拷贝文件:  
  BOOL   CopyFile(  
      LPCTSTR   lpExistingFileName,   //   name   of   an   existing   file  
      LPCTSTR   lpNewFileName,             //   name   of   new   file  
      BOOL   bFailIfExists                     //   operation   if   file   exists  
  );  
 

发表者:lixiaosan

BOOL   PathFileExists(                     LPCTSTR   pszPath  
  );  
  Header   shlwapi.h    
  Import   library   shlwapi.lib    
   
   
  BOOL   CopyFile(  
      LPCTSTR   lpExistingFileName,   //   name   of   an   existing   file  
      LPCTSTR   lpNewFileName,             //   name   of   new   file  
      BOOL   bFailIfExists                     //   operation   if   file   exists  
  );


 

 
热门推荐笔记本: 方正笔记本
相关文章:
webmaster:popbb@126.com   最佳浏览:1024X768 MSIE
©2007 popbb.net All Rights Reserved