代码如下:
//ofstream outfile(T2CA(LPCTSTR(strAppXmlRoot)), ios::ate | ios::binary);
ofstream outfile("C:\\Documents and Settings\\Administrator\\桌面\\LEE\\Mfc\\Test007\\AppDemo.xml",
ios::ate | ios::binary);
outfile.write(T2CA(LPCTSTR(strHead)),strHead.GetLength());
ofstream outfile1("C:\\app.xml",ios::ate | ios:: binary);
outfile1.write(T2CA(LPCTSTR(strHead)),strHead.GetLength());
outfile.close();
outfile1.close();
HANDLE hFile=::CreateFile(_T("C:\\test.xml"),GENERIC_WRITE,0,NULL,CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL,NULL);
if(hFile)
{
DWORD DW;
::WriteFile(hFile,LPCTSTR(strHead),strHead.GetLength(),&DW,NULL);
}
CloseHandle(hFile);问题1:outfile1能正常写入,但是上outfile写不进去,字节为0;
问题2:用api和CFile类都不能正确写入。
附,写入内容为:#define HEAD_INDEX_XMLFILE _T("<?xml version=\"1.0\" encoding=\"GB2312\"?>\n\
<AppRegInfo>\n\
<Action></Action>\n\
<AppName>ALL</AppName>\n\
<Request_Type></Request_Type>\n\
<Response_Type>NONE</Response_Type>\n\
<Sender>AnyOne</Sender >\n\
<Receiver StateType=\"OnLine\"></Receiver>\n\
</AppRegInfo>")
//ofstream outfile(T2CA(LPCTSTR(strAppXmlRoot)), ios::ate | ios::binary);
ofstream outfile("C:\\Documents and Settings\\Administrator\\桌面\\LEE\\Mfc\\Test007\\AppDemo.xml",
ios::ate | ios::binary);
outfile.write(T2CA(LPCTSTR(strHead)),strHead.GetLength());
ofstream outfile1("C:\\app.xml",ios::ate | ios:: binary);
outfile1.write(T2CA(LPCTSTR(strHead)),strHead.GetLength());
outfile.close();
outfile1.close();
HANDLE hFile=::CreateFile(_T("C:\\test.xml"),GENERIC_WRITE,0,NULL,CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL,NULL);
if(hFile)
{
DWORD DW;
::WriteFile(hFile,LPCTSTR(strHead),strHead.GetLength(),&DW,NULL);
}
CloseHandle(hFile);问题1:outfile1能正常写入,但是上outfile写不进去,字节为0;
问题2:用api和CFile类都不能正确写入。
附,写入内容为:#define HEAD_INDEX_XMLFILE _T("<?xml version=\"1.0\" encoding=\"GB2312\"?>\n\
<AppRegInfo>\n\
<Action></Action>\n\
<AppName>ALL</AppName>\n\
<Request_Type></Request_Type>\n\
<Response_Type>NONE</Response_Type>\n\
<Sender>AnyOne</Sender >\n\
<Receiver StateType=\"OnLine\"></Receiver>\n\
</AppRegInfo>")
解决方案 »
- CRichEditCtrl怎么设置上标,下标
- 如何根据一个可执行文件名,得到其运行时的进程名?比如文件名为CoralQQ.exe,运行起来进程名是QQ.exe
- 在一个客户区作出一个右键菜单容易,但是在一个LISTCONTROL 上如何实现右键菜单了
- 如何在View类中添加变量 public:CString text;
- 求助:我的程序编译的时候,重叠io的变量类型都识别不了,出来很多error怎么办?
- 问个简单的问题,关于系统自动生成的菜单
- 关于ASP组件的问题
- 高分急问如何在指定的区域内用CDC画图?????????????
- 束手无策?
- 怎样屏蔽View中的关闭窗口按钮
- 单线程处理多个套接字
- visual studio 2008 里面运行不了这个程序
CFile f;
f.Open(_T("C:\\test.xml"),CFile::modeCreate|CFile::modeWrite);
CStrint cstr = _T("写入内容");
f.Write(cstr,cstr.GetLength());//或者指向文件缓冲区等任何地方
f.Close();
<AppRegInfo>\n\
<Action></Action>\n\
<AppName>ALL</AppName>\n\
<Request_Type></Request_Type>\n\
<Response_Type>NONE</Response_Type>\n\
<Sender>AnyOne</Sender >\n\
<Receiver StateType=\"OnLine\"></Receiver>\n\
</AppRegInfo>")
===================================
就是个字符串啊,保存时把它保存为XML
试试,结果都不行。
解决方法。http://www.cppblog.com/gohan/archive/2008/05/11/49488.html
这个路径存在吗?如果只有
C:\\Documents and Settings\\Administrator\\桌面\\LEE\\Mfc\\
程序是不能自动建立“Test007”目录的。