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

📄 umfilename.cpp

📁 中央气象台与日本台风数据之间的格式转换程序
💻 CPP
字号:

#include "stdafx.h"
#include "UmFileName.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CUmFileName::CUmFileName(CString szFileName)
{
	m_szFileName = szFileName;
}

CUmFileName::~CUmFileName()
{

}

void CUmFileName::SetFileName(CString szFileName)
{
	m_szFileName = szFileName;
}

/*****************************************************************
*
*	Function:	GetFileName()
*
*	Purpose:	Retrieves current filename minus the path
*
*	Remarks:	if the filename is "c:\incoming\hello.txt", this
*				function returns "hello.txt".
*
******************************************************************/
CString CUmFileName::GetFileName()
{
	CString szFileName;

	_splitpath(m_szFileName, m_szDrive, m_szDir, m_szFname, m_szExt);
	szFileName = m_szFname;
	szFileName += m_szExt;

	return szFileName;
}

/*****************************************************************
*
*	Function:	GetRoot()
*
*	Purpose:	Retrieves the path only of the current filename.
*
*	Remarks:	if the filename is "c:\incoming\hello.txt", this
*				function returns "c:\incoming\".
*
******************************************************************/
CString CUmFileName::GetRoot()
{
	CString szFileName;

	_splitpath(m_szFileName, m_szDrive, m_szDir, m_szFname, m_szExt);
	szFileName = m_szDrive;
	szFileName += m_szDir;

	return szFileName;
}

/*****************************************************************
*
*	Function:	GetFileTitle()
*
*	Purpose:	Retrieves the title of the filename excluding
*				the path and extension.
*
*	Remarks:	if the filename is "c:\incoming\hello.txt", this
*				function returns "hello".
*
******************************************************************/
CString CUmFileName::GetFileTitle()
{
	CString szFileName;

	_splitpath(m_szFileName, m_szDrive, m_szDir, m_szFname, m_szExt);
	szFileName = m_szFname;

	return szFileName;
}

/*****************************************************************
*
*	Function:	GetDescription()
*
*	Purpose:	Returns the description of the file
*
******************************************************************/
CString CUmFileName::GetDescription()
{
	CString		szTypeName;
	SHFILEINFO	sfi;

	SHGetFileInfo(m_szFileName,
                 0,
                 &sfi, 
                 sizeof(SHFILEINFO), 
                 SHGFI_TYPENAME);

   szTypeName = sfi.szTypeName;

   return szTypeName;
}

/*****************************************************************
*
*	Function:	Exists()
*
*	Purpose:	Determines whether a file or directory exists.
*
******************************************************************/
bool CUmFileName::Exist()
{
	WIN32_FIND_DATA fd;

	CString	szFindPath=m_szFileName;
	int nSlash = szFindPath.ReverseFind('\\');

	if( nSlash == szFindPath.GetLength()-1)
	{
		szFindPath = szFindPath.Left(nSlash);
	}

	HANDLE hFind = FindFirstFile( szFindPath, &fd );

	if ( hFind != INVALID_HANDLE_VALUE )
	{
		FindClose( hFind );
	}

	return hFind != INVALID_HANDLE_VALUE;
}


⌨️ 快捷键说明

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