Symbian 文件读写及读写流的方法
2010-03-18 20:53:00 来源:WEB开发网{
...
private:
// Data
TUint8 iX1;
TUint16 iX2;
TUint32 iX3;
TInt8 iY1;
TInt16 iY2;
TInt32 iY3;
TReal32 iZ1
TReal64 iZ2;
};
void CMyObject::ExternalizeL(RWriteStream& aStream)
{
aStream.WriteUint8L( iX1 );
aStream.WriteUint16L( iX2 );
aStream.WriteUint32L( iX3 );
aStream.WriteInt8L( iY1 );
aStream.WriteInt16L( iY2 );
aStream.WriteInt32L( iY3 );
aStream.WriteReal32( iZ1 );
aStream.WriteReal64( iZ2 );
}
void CMyObject::InternalizeL(RReadStream& aStream)
{
iX1 = aStream.ReadUint8L();
iX2 = aStream.ReadUint16L();
iX3 = aStream.ReadUint32L();
iY1 = aStream.ReadInt8L();
iY2 = aStream.ReadInt16L();
iY3 = aStream.ReadInt32L();
iZ1 = aStream.ReadReal32();
iZ2 = aStream.ReadReal64();
}
CMyObject iObject;
...
RFs& fs = CCoeEnv::Static()->FsSession();
RFileReadStream readStream;
RFileWriteStream writeStream;
writeStream.Create(fs, KTxtFileName, EFileWrite);
writeStream.PushL();
iObject.ExternalizeL(writeStream);
writeStream.CommitL();
writeStream.Pop();
writeStream.Release();
readStream.Open(fs, KTxtFileName, EFileRead));
readStream.PushL();
iObject.InternalizeL(readStream);
readStream.Pop();
readStream.Release();
c. 删除文件
RFs::Delete(): 删除指定的文件,该文件不能处于打开状态,并且它不能是系统或只读文件
RFs::RmDir():删除指定的目录,目录名必须以"\"结尾,该目录必须为空,且不能为根目录
Symbian文件操作整理
本文不断更新中…
更多精彩
赞助商链接