⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 teach_sp_54.htm

📁 VC专题教程 -- 第一章 Internet相关开发 打包下载 --- 1.1 如何编写CGI程序 ------ 1.2 一种更亲切的CGI开发系统WinCGI ------ 1.3 利用ISAPI开
💻 HTM
字号:

<!-- LANGUAGE='JavaScript'>write_body();<-->
<!-- LANGUAGE='JavaScript'>write_bar();<-->



<table width=98% cellspacing="0" cellpadding="0" align=center><!--整体框架-->
<tr><td>

<table border=0 width="100%" cellspacing="0" cellpadding="2"><!--标记放置区域-->
<tr>
	<td width="30%" align="center" bgcolor="#8E8E8E" valign=middle><img src=../../img/brand_200_60.gif width=200 height=60 alt="LOGO1"></td>
	<td width="70%" align="center" bgcolor="#8E8E8E" valign=middle><!-- LANGUAGE='JavaScript'>write_ban();<--></td>
</tr>
<tr>
	<td colspan="2" bgcolor="#939393" align=center><font color=white>您当前位置</font> <a href=../../index.htm><font color=white>首页</font></a> <a href=../index.htm><font color=white>开发教程</font></a> <a href=index.htm><font color=white><font class=engul>Visual C++/MFC</font>专题讲座</font></a> <font color=white>5.4 磁盘文件的其他操作</font> <font color=white><!-- LANGUAGE='JavaScript'>write_command();<--></font></td>
</tr>
</table><!--标记放置区域 END-->

<table border=0 width=100% cellspacing="0" cellpadding="0">
<tr bgcolor="#F4F4F4">
<td><!-- article title begin here-->
<br>
<p align=center><big>5.4 磁盘文件的其他操作</big>
<p>在Win32中还提供了很多文件操作的函数,如同拷贝,移动和获取文件属性等。
<p>文件的拷贝可以通过CopyFile函数进行,函数原型为:
<pre>
BOOL CopyFile(
  LPCTSTR lpExistingFileName, // 源文件名
  LPCTSTR lpNewFileName,      // 目标文件名
  BOOL bFailIfExists          // 在目标文件存在时是否覆盖该文件
);
BOOL CopyFileEx(
  LPCTSTR lpExistingFileName,           // 源文件名
  LPCTSTR lpNewFileName,                // 目标文件名
  LPPROGRESS_ROUTINE lpProgressRoutine, // 回调函数
  LPVOID lpData,                        // 传递给回调函数的参数
  LPBOOL pbCancel,                      // 取消参数,如果在执行过程中将这个变量设为FALSE拷贝过程将会取消
  DWORD dwCopyFlags                     // 拷贝参数
);
</pre>
<p>其中CopyFileEx可以提供一个回调函数,并且在拷贝过程中CopyFileEx会调用这个回调函数。
<p>文件的删除可以利用DeleteFile,
<pre>
BOOL DeleteFile(
  LPCTSTR lpFileName   // file name
);
</pre>
<p>文件的移动利用MoveFile,在文件移动时可以移动文件和目录(包括子目录)
<pre>
BOOL MoveFile(
  LPCTSTR lpExistingFileName, // 源文件名
  LPCTSTR lpNewFileName       // 目标文件名
);
</pre>
<p>文件的属性的获得和设置可以利用GetFileAttributes和SetFileAttributes
<pre>
DWORD GetFileAttributes(
  LPCTSTR lpFileName   // 文件名
);//返回值为文件属性
BOOL SetFileAttributes(
  LPCTSTR lpFileName,      // 文件名
  DWORD dwFileAttributes   // 新属性
);</pre>
<p>此外GetShortPathName可以将长文件名转换为短文件名
<pre>
DWORD GetShortPathName(
  LPCTSTR lpszLongPath,  // 长文件名
  LPTSTR lpszShortPath,  // 短文件名
  DWORD cchBuffer        // 短文件名缓冲区大小
);
</pre>
<p>

                  <p align=center><a href=index.htm#charpter5>返回</a></p>
<p align=center><small>版权所有 闻怡洋 <a href=http://www.vchelp.net/><font class=engul>http://www.vchelp.net/<font></font></font></a></small></p>
</small>
	</td></tr><!-- article content end-->
	</table>
</td>
</tr><!-- article title end-->
</table>

</td></tr></table><!--整体框架 END-->



<!-- LANGUAGE='JavaScript'>write_tail();<-->


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -