如果判断并去掉文件的只读属性
同上 问题点数:46、回复次数:4Top
1 楼greenteanet(扎扎实实打基础,保持一颗平常心。)回复于 2005-01-21 23:05:28 得分 2
不会Top
2 楼oo(为了名副其实,努力学习oo技术ing)回复于 2005-01-21 23:11:40 得分 16
from MSDN:
char* pFileName = "test.dat";
if( CFile::GetStatus( pFileName, status ) ) // static function
{
#ifdef _DEBUG
afxDump << "Full file name = " << status.m_szFullName << "\n";
#endif
}
/*status 说明
enum Attribute {
normal = 0x00,
readOnly = 0x01,
hidden = 0x02,
system = 0x04,
volume = 0x08,
directory = 0x10,
archive = 0x20
};
*/
CFile::SetStatus
static void SetStatus( LPCTSTR lpszFileName, const CFileStatus& status );
Top
3 楼EnochShen(小疯子:真的好菜—知耻而后勇!)回复于 2005-01-21 23:37:00 得分 20
#include "stdafx.h"
#include <WTypes.h>
#include <Winbase.h>
int main(int argc, char* argv[])
{
char* lpFileName = "C:\\test.txt";
DWORD dwAttribute = ::GetFileAttributes(lpFileName);
if(dwAttribute & FILE_ATTRIBUTE_READONLY)
{
dwAttribute &= ~FILE_ATTRIBUTE_READONLY;
SetFileAttributes(lpFileName,dwAttribute);
printf("FILE_ATTRIBUTE_READONLY Removed\r\n");
}
return 0;
}Top
4 楼TomDebug(风)回复于 2005-01-22 12:45:25 得分 8
from MSDN:
char* pFileName = "test.dat";
if( CFile::GetStatus( pFileName, status ) ) // static function
{
#ifdef _DEBUG
afxDump << "Full file name = " << status.m_szFullName << "\n";
#endif
}
/*status 说明
enum Attribute {
normal = 0x00,
readOnly = 0x01,
hidden = 0x02,
system = 0x04,
volume = 0x08,
directory = 0x10,
archive = 0x20
};
*/
CFile::SetStatus
static void SetStatus( LPCTSTR lpszFileName, const CFileStatus& status );
--------------------------
解释的很清楚Top




