我想用VC创建个文本文件,代码该如何写呢?比如我想在d:创建dve.txt的文件同时对他进行读写操作。请高手详细做答,小弟谢了!
解决方案 »
- CWaveFile Opne Write 都是无法解析的外部符号
- XTP界面中,怎样设置menu不能拖动出来
- 如何访问到类外的P2()函数??
- 我对完成端口的流程还有一点不明白,哪位高手可以指点一下:(
- 请教VC的小问题!!!!
- VC中否用游标,如何用,请指点!高手.
- 哪里有VC关于ADO编程的书籍或帮助下载?
- 高手请教,c#调用ATL做的dll,参数遇到问题??
- 求助,MFC无法截图的问题(目标窗口非DX绘制)
- 用VB开发COM+怎样调用一个用VC开发的基于IUKNOW接口的接口 (急用)
- 在windows平台下使用STL。使用了string模板类,请问string是否支持Unicode字符集?我们知道在windows下编程,为了只保持一份源代码,我们
- 用UDP接收数据也一定要知道发送数据方的IP和端口?
http://community.csdn.net/Expert/topic/3972/3972572.xml?temp=.567898
fp = fopen("d:\\dve.txt","w");
if(fp == NULL)
AfxMessageBox("文件创建失败");
fwrite("http://www.sunxin.org",1,strlen("http://www.sunxin.org"),pFile);
//fseek(pFile,0,SEEK_SET);
//fwrite("ftp:",1,strlen("ftp:"),pFile);
//fwrite("http://www.sunxin.org",1,strlen("http://www.sunxin.org"),pFile);
fclose(pFile);*/
//fflush(pFile);/* FILE *pFile=fopen("2.txt","wb");
char ch[3];
ch[0]='a';
ch[1]=10;
ch[2]='b';
fwrite(ch,1,3,pFile);
fclose(pFile);*/ /*FILE *pFile=fopen("3.txt","w");
int i=98341;
char ch[5];*/
/*ch[0]=9+48;
ch[1]=8+48;
ch[2]=3+48;
ch[3]=4+48;
ch[4]=1+48;*/
/*itoa(i,ch,10); //fwrite(&i,4,1,pFile);
fwrite(ch,1,5,pFile);
fclose(pFile);*//* ofstream ofs("4.txt");
ofs.write("http://www.sunxin.org",strlen("http://www.sunxin.org"));
ofs.close();*/
/* HANDLE hFile;
hFile=CreateFile("5.txt",GENERIC_WRITE,0,NULL,CREATE_NEW,
FILE_ATTRIBUTE_NORMAL,NULL);
DWORD dwWrites;
WriteFile(hFile,"http://www.sunxin.org",strlen("http://www.sunxin.org"),
&dwWrites,NULL);
CloseHandle(hFile);*/
/* CFile file("6.txt",CFile::modeCreate | CFile::modeWrite);
file.Write("http://www.sunxin.org",strlen("http://www.sunxin.org"));
file.Close();*/取掉注释就是一种方法
CFile file("d:\\dve.txt",CFile::modeCreate|CFile::modeWrite);
file.Write("11111111",8);
file.Close();2.
char buffer[17];
CFile file("d:\\dve.txt",CFile::modeRead);
file.Read(buffer,16);
file.Close();
CString str_temp;
str_temp = _T("d:\\dve.txt");
hFile= ::CreateFile(str_temp,
GENERIC_READ | GENERIC_WRITE,
0,
NULL,
OPEN_ALWAYS,
FILE_ATTRIBUTE_NORMAL,
NULL); if (hFile == INVALID_HANDLE_VALUE)
{
AfxMessageBox(_T("Couldn't create the file!"));
}
else
{
CFile myFile((int)hFile); static const char sz[20] = "Hockey is best!";
myFile.Write(sz, lstrlen(sz));
myFile.Close();
}
///////////////////