查看单个帖子
旧 2009-05-07, 03:23 PM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】save File Changes

save file changes
save file changes
i tried to change dwg file and save it as follows. it threw an error "can not open file" while calling createfile in "write" mode (line 2). i thought that it was because the same file was already opened in line 1. then i changed line 2 to create a new file c:\test.dwg. it worked. i saved file changes to a new file. so my question is how to save file changes to itself?
thanks for any help.
oddbdatabaseptr pdb;
pdb = m_svcs.readfile( strftoprocess, false, false, oda::ksharedenyno ); // line 1
try
{
// change file here
}
catch(...)
{
//error handling code here
return;
}
odstreambufptr pfile;
oddb::savetype type = pdb->originalfiletype();
oddb:: dwgversion version = pdb->originalfileversion();
try
{
pfile = m_svcs.createfile(strftoprocess, oda::kfilewrite, oda::ksharedenywrite, oda::kopenexisting); // line 2
pdb->writefile(pfile, type, version, true);
}
catch(oderror& e)
{
// error handler
return;
}
last edited by xidongzhang; 9th february 2004 at 07:34 amfff">.
just use the
oddbdatabase::writefile()
method to write back. you don't need to re-create the same file.
thanks, walt.
but the first parameter of oddbdatabase::writefile() is odstreambuf* pfilebuff. how can we get the file buffer? (that's why i created the same file again.)
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)