Symbian 读写 INI 配置文件的方法
2010-04-20 16:06:00 来源:WEB开发网fs.Close();
return true;
}
if(KErrNone==fs.MkDirAll(aPath) ){
fs.Close();
return true;
}
fs.Close();
return false;
}
void CFile::GetDirFiles(const TDesC& path,CDesCArray& files)
{
RFs fs;
User::LeaveIfError(fs.Connect() );
if( BaflUtils::FolderExists(fs,path) ){
CDir* dir=NULL;
User::LeaveIfError( fs.GetDir(path, KEntryAttNormal|KEntryAttMatchMask, ESortByName, dir) );
TInt ii=dir->Count();
for(TInt i=0;i
TEntry aEntry=(*dir)[i];
TBuf<256> filePath(path);
filePath.Append(aEntry.iName);
files.AppendL(filePath);
}
}
fs.Close();
}
void CFile::LogToFile(const TDesC& filename,TDesC8& pdu)
{
//_LIT(name, “C:\log.txt”);
//TBuf<32> filename(name);
RFs fs;
RFile file;
User::LeaveIfError(fs.Connect() );
//CleanupClosePushL(fs);
//CleanupClosePushL(file);
TUint shareMode=EFileRead | EFileWrite ;
TInt err= file.Open( fs, filename,shareMode ) ;
if(err==KErrNotFound) // file does not exist ? create it
err=file.Create(fs,filename,shareMode);
TInt pos;
file.Seek(ESeekEnd,pos);
if(err!=KErrNotFound)
file.Write(pos,_L8(“ ”));
file.Seek(ESeekEnd,pos);
file.Write(pos,pdu);
//CleanupStack::PopAndDestroy(2,&fs);
file.Close();
fs.Close();
}
void CFile::GetLinesFromFile(const TDesC& filename,CDesCArray& lines){
RFs fs;
User::LeaveIfError(fs.Connect() );
if( BaflUtils::FileExists(fs,filename) ){
更多精彩
赞助商链接