?? myfile.cpp
字號:
// MyFile.cpp: 實現CMyFile類.
//
#include "stdafx.h"
#include "MyFile.h"
CMyFile myfile;
//---------------------------------------------------------------------------
CMyFile::CMyFile()
{
}
//---------------------------------------------------------------------------
CMyFile::~CMyFile()
{
}
//---------------------------------------------------------------------------
BOOL CMyFile::FileExists(LPCTSTR lpszFileName)
{
DWORD dwAttributes = GetFileAttributes(lpszFileName);
if (dwAttributes == 0xFFFFFFFF)
return FALSE;
if ((dwAttributes & FILE_ATTRIBUTE_DIRECTORY)
== FILE_ATTRIBUTE_DIRECTORY)
{
return FALSE;
}
else{
return TRUE;
}
}
//---------------------------------------------------------------------------
FILE* CMyFile::GetFilePointer(LPCTSTR lpszFileName)
{
FILE *fp;
if(FileExists(lpszFileName)){
// 打開已有文件進行寫數據.
fp=fopen(lpszFileName,"r+b");
}
else{
// 創建新文件進行寫數據.
fp=fopen(lpszFileName,"w+b");
if(fp==NULL) AfxMessageBox("error");
}
return fp;
}
//---------------------------------------------------------------------------
DWORD CMyFile::GetFileSizeByName(LPCTSTR lpszFileName)
{
if(!FileExists(lpszFileName)) return 0;
struct _stat ST;
// 獲取文件長度.
_stat(lpszFileName, &ST);
UINT nFilesize=ST.st_size;
return nFilesize;
}
//---------------------------------------------------------------------------
// 從全程文件名中提取短文件名.
CString CMyFile::GetShortFileName(LPCSTR lpszFullPathName)
{
CString strFileName=lpszFullPathName;
CString strShortName;
strFileName.TrimLeft();
strFileName.TrimRight();
int n=strFileName.ReverseFind('/');
strShortName=strFileName.Right(strFileName.GetLength()-n-1);
return strShortName;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -