1、如何通过程序的参数传进去要处理的文件路径信息,调试时候呢?怎么办?
2、如何删除带有只读属性的文件?
3、系统的剪切功能大家都知道,能不能写个函数,实现文件的剪切功能,支持覆盖与非覆盖;
4、如何更改一个文件的类型扩展名呢?
#include <Windows.h> #include <tchar.h> BOOL DeleteReadOnlyFile(LPCTSTR lpFileName) { DWORD dwRet = GetFileAttributes(lpFileName); if (dwRet == INVALID_FILE_ATTRIBUTES) return FALSE; if (dwRet & FILE_ATTRIBUTE_READONLY) { dwRet &= ~FILE_ATTRIBUTE_READONLY; SetFileAttributes(lpFileName, dwRet); } return DeleteFile(lpFileName); } BOOL CutFile(LPCTSTR lpExistingFileName, LPCTSTR lpNewFileName, BOOL bFailIfExists) { BOOL bRet = CopyFile(lpExistingFileName, lpNewFileName, bFailIfExists); if (bRet) bRet = DeleteReadOnlyFile(lpExistingFileName); return bRet; } int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, INT nCmdShow) { BOOL a = CutFile(_T("D:\\1.txt"),_T("D:\\Game\\1.txt"),0); MoveFile(_T("D:\\q.txt"), _T("D:\\zz.bat")); return 0; }
原文:https://www.cnblogs.com/SakuraQAQ/p/14295078.html