本文主要是对涉及文件操作的各种函数整理, 提供文件及路径常用操作,后续会不定期更新,欢迎大家一起学习交流~
在VS2008下编译生成目标动态库文件,使用多字节,编译测试通过,以下是源代码相关:
FilesOperationEx.h文件内容如下:
// FilesOperationEx.h : main header file for the FilesOperationEx DLL
//
/************************************************************************/
/* Copyright (c) 2017, by 1031800228@qq.com
/* All rights reserved.
/*
/* 文件名称: FilesOperationEx.h
/* 文件标识:
/* 摘要: 对涉及文件操作的各种函数进行汇总, 提供文件及路径常用操作
/* 当前版本: 1.0
/* 作者: 1031800228@qq.com
/* 完成日期: 2017年12月22日
/************************************************************************/
#pragma once
#ifndef __AFXWIN_H__
#error "include 'stdafx.h' before including this file for PCH"
#endif
#include "resource.h" // main symbols
#include <fstream>
#include <iostream>
using namespace std;
// CFilesOperationExApp
// See FilesOperationEx.cpp for the implementation of this class
//
class CFilesOperationExApp : public CWinApp
{
public:
CFilesOperationExApp();
//************************************************************************
// Author: 2017/08/16 add by 1031800228@qq.com
// Method: filesEx_ExistsFileName
// FullName: CFilesOperationExApp::ExistsFileName
// Access: public
// Returns: BOOL
// Parameter: const CString & strFileName
// Qualifier:
// Description: 判断一个文件是否存在
//************************************************************************
BOOL filesEx_ExistsFileName(const CString &strFileName);
//************************************************************************
// Author: 2017/08/16 add by 1031800228@qq.com
// Method: filesEx_MyCreatePath
// FullName: CFilesOperationExApp::filesEx_MyCreatePath
// Access: public
// Returns: BOOL
// Parameter: const CString & strPath
// Qualifier:
// Description: 创建一个目录,如果存在则不创建
//************************************************************************
BOOL filesEx_MyCreatePath(const CString &strPath);
//************************************************************************
// Author: 2017/07/24 add by 1031800228@qq.com
// Method: filesEx_CalcFilesCntForAFolder
// FullName: CFilesOperationExApp::CalcFilesCntForAFolder
// Access: public
// Returns: int
// Parameter: const CString & strFolderPath
// Qualifier:
// Description: 计算一个文件夹下的文件个数
//************************************************************************
int filesEx_CalcFilesCntForAFolder(const CString &strFolderPath);
//************************************************************************
// Author: 2017/12/22 add by 1031800228@qq.com
// Method: filesEx_GetCurrentAppPath
// FullName: CFilesOperationExApp::filesEx_GetCurrentAppPath
// Access: public
// Returns: CString
// Qualifier:
// Description: 获取本执行程序所在的路径
//************************************************************************
CString filesEx_GetCurrentAppPath();
//************************************************************************
// Author: 2017/12/22 add by 1031800228@qq.com
// Method: filesEx_IsPathExist
// FullName: CFilesOperationExApp::filesEx_IsPathExist
// Access: public
// Returns: BOOL
// Parameter: const CString & strPath
// Qualifier:
// Description: 判断目标路径是否存在
//************************************************************************
BOOL filesEx_IsPathExist(const CString &strPath);
//************************************************************************
// Author: 2017/12/22 add by 1031800228@qq.com
// Method: filesEx_IsFileExist
// FullName: CFilesOperationExApp::filesEx_IsFileExist
// Access: public
// Returns: BOOL
// Parameter: const CString & strFileName
// Qualifier:
// Description: 判断目标文件是否存在
//************************************************************************
BOOL filesEx_IsFileExist(const CString &strFileName);
//************************************************************************
// Author: 2017/12/22 add by 1031800228@qq.com
// Method: filesEx_CreateMultiLevelPath
// FullName: CFilesOperationExApp::filesEx_CreateMultiLevelPath
// Access: public
// Returns: BOOL
// Parameter: const CString & strPath
// Qualifier: strPath 合法: "D:\\abc\\me" 或 "me\\you" 或 ""; 不合法: "D:\\abc\\me\\" 或 "me\\you\\" 或 "\\";
// Description: 创建一个多层目录,如果存在就不创建
//************************************************************************
BOOL filesEx_CreateMultiLevelPath(const CString &strPath);
//************************************************************************
// Author: 2017/12/22 add by 1031800228@qq.com
// Method: filesEx_MyWriteIniFile
// FullName: CFilesOperationExApp::filesEx_MyWriteIniFile
// Access: public
// Returns: BOOL
// Parameter: const CString & strFilePath
// Parameter: const CString & strSession
// Parameter: const CString & str
// Qualifier:
// Description: 写INI格式日志信息到指定文件
//************************************************************************
BOOL filesEx_MyWriteIniFile(const CString& strFilePath, const CString& strSession, const CString& str);
//************************************************************************
// Author: 2017/12/22 add by 1031800228&