vc6如何用语句在硬盘上建立一个文本文件? 就是先判断硬盘上有无“c:\abc.txt”文件,如果没有则建立该文件,如果已有就不做操作退出。谢谢! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 BOOL CreateFileEx(CString sFile){ CString sDir; sDir = sFile.Left(sFile.ReverseFind('\\') + 1); //循环创建目录 if (!IsFileExist(sDir)) { CString tmp; int n = sDir.Find('\\'); while (tmp != sDir) { n = sDir.Find('\\', n+1); tmp = sDir.Left(n + 1); if (!IsFileExist(tmp)) { if (!CreateDirectory(tmp, NULL)) return FALSE; } } } HANDLE h = CreateFile(sFile, GENERIC_READ, FILE_SHARE_READ, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL); if (h == NULL) return FALSE; else { CloseHandle(h); return TRUE; }}createfile(){CString s = "c:\abc.txt"if (!PathFileExists(s)){ CreateFileEx(s);}} mfc?Cfile("c:\\abc.txt",CFile::modeCreate |CFile::modeNoTruncate )这个可以吗? 年初简历--求指导今年的路(准备下年跳槽) 如何遍历网络文件 static text 界面刷新文字内容的问题 高分 非主线程写视图的问题 弹出式对话框问题 怎样在ListView中添加进度条啊? 如何取得OnDraw函数调用的CDC对象? 简单画图问题 有没有pdg文件转其他格式的工具? 怎样在vc中引用vb 中RegExp对象?怎样使用外在的DLL?? 点击列头,会产生HeadClick事件,能够直接得到所点的列号ColIndex,我想知道他是怎么算出这个列号的,怎么办? 如何在WINDOWXP下把网卡设置为混杂模式。
{
CString sDir;
sDir = sFile.Left(sFile.ReverseFind('\\') + 1);
//循环创建目录
if (!IsFileExist(sDir))
{
CString tmp;
int n = sDir.Find('\\');
while (tmp != sDir)
{
n = sDir.Find('\\', n+1);
tmp = sDir.Left(n + 1);
if (!IsFileExist(tmp))
{
if (!CreateDirectory(tmp, NULL))
return FALSE;
}
}
}
HANDLE h = CreateFile(sFile,
GENERIC_READ,
FILE_SHARE_READ,
NULL,
CREATE_NEW,
FILE_ATTRIBUTE_NORMAL,
NULL);
if (h == NULL)
return FALSE;
else
{
CloseHandle(h);
return TRUE;
}
}createfile()
{
CString s = "c:\abc.txt"
if (!PathFileExists(s))
{
CreateFileEx(s);
}
}
Cfile("c:\\abc.txt",CFile::modeCreate |CFile::modeNoTruncate )
这个可以吗?