RFile.Write()的奇怪问题,老是提示EXEC0错误

zc806 2012-01-12 04:05:26
从新写了段测试代码一样出错,是不是还有哪里需要配的呢,代码如下:

//////////////////////////////////////////////////////
_LIT( KLocalDataFilePathxx, "c:\\data\\WorldInEye\\File\\device.xml" );
HBufC* iFilePath;
iFilePath = HBufC::NewL( 64 );
iFilePath->Des().Copy( KLocalDataFilePathxx );
RFs iFs;
iFs.Connect();

RFile file;
TRAPD( err, file.Replace( iFs, iFilePath->Des(), EFileWrite ) );
if ( err != KErrNone )
{
User::Leave( err );
}
HBufC8* content = HBufC8::NewL( 1024 );
content->Des().Append( KLocalDataFilePathxx );
TRAP( err, file.Write( *content ) );
if ( err != KErrNone )
{
User::Leave( err );
}

file.Close();
SAFE_DELETE(iFilePath);
SAFE_DELETE(content);
/////////////////////////////////////////////////////////
走到TRAP( err, file.Write( *content ) );就出错,提示EXEC0,最后发现file的句柄是无效的,为什么file的句柄会变成无效呢?请高手解答!!!
...全文
2492 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
浪子 2012-01-13
  • 打赏
  • 举报
回复
//////////////////////////////////////////////////////
_LIT( KLocalDataFilePathxx, "c:\\data\\WorldInEye\\File\\device.xml" );
HBufC* iFilePath;
iFilePath = HBufC::NewL( 64 );
iFilePath->Des().Copy( KLocalDataFilePathxx );
RFs iFs;
iFs.Connect();

BaflUtils::EnsurePathExistsL(iFs, KLocalDataFilePathxx);

RFile file;
TRAPD( err, file.Replace( iFs, iFilePath->Des(), EFileWrite ) );
if ( err != KErrNone )
{
User::Leave( err );
}
HBufC8* content = HBufC8::NewL( 1024 );
content->Des().Append( KLocalDataFilePathxx );
TRAP( err, file.Write( *content ) );
if ( err != KErrNone )
{
User::Leave( err );
}

file.Close();
SAFE_DELETE(iFilePath);
SAFE_DELETE(content);

3,120

社区成员

发帖
与我相关
我的任务
社区描述
塞班系统(Symbian系统)是塞班公司为手机而设计的操作系统,它的前身是英国宝意昂公司的 EP ( Electronic Piece of cheese)操作系统。
社区管理员
  • Symbian社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧