×

Discussion Board

Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    Regular Contributor
    Join Date
    May 2007
    Posts
    320

    Problem in Reading a file using RFileReadStream

    Hi friends,
    I am reading a file using RFileReadStream object.
    Code:
    inputFileStream.ReadL(rData);
    I am using this to read the data from file. Totally I m reading 2 files. First file properly gets read. Problem occurs at the end of second file reading. System error -25 (End Of File reading) is coming.
    Is there any specific way to remove this error? The file which I am reading is a text file.
    If anybody know about this Please tell me.
    Thanks in advance.
    Ashfaque.
    Life is Short..... Live it with Positive Attitude...

  2. #2
    Regular Contributor
    Join Date
    Apr 2006
    Location
    India
    Posts
    383

    Re: Problem in Reading a file using RFileReadStream

    The error code KErrEof (-25) is self explanatory..

    System wide error code -25 : indicates that end of file has been reached.

    A system wide error code indicates an error in the environment, or in
    user input from which a program may recover.

    Note that RFile::Read() is a higher-level interface. When the end of
    the file is reached, it returns zero bytes in the destination descriptor, and
    a KErrNone return value. KErrEof is not used for this purpose; other error
    conditions are returned only if some other error condition was indicated on
    the file.
    Regards,
    Shilpa Kulkarni

  3. #3
    Super Contributor
    Join Date
    Mar 2004
    Location
    Singapore
    Posts
    9,968

    Re: Problem in Reading a file using RFileReadStream

    if you know the length of the File Try using

    Code:
    inputFileStream.ReadL(rData, aLength);

  4. #4
    Regular Contributor
    Join Date
    May 2007
    Posts
    320

    Re: Problem in Reading a file using RFileReadStream

    Quote Originally Posted by Shilpa13 View Post
    The error code KErrEof (-25) is self explanatory..
    Hi Shilpa,
    Thanx for the help. I am not getting why this is coming. First file is properly getting read only problem occurs at the end of second file. First file is numeric while second is alphanumeric.
    Do you know answer for this. Please tell me I am really confused in this.
    Life is Short..... Live it with Positive Attitude...

  5. #5
    Regular Contributor
    Join Date
    May 2007
    Posts
    320

    Re: Problem in Reading a file using RFileReadStream

    Quote Originally Posted by skumar_rao View Post
    if you know the length of the File Try using

    Code:
    inputFileStream.ReadL(rData, aLength);
    Problem is that length of each file is different. To do this I have to make different functions for reading a file.....
    Life is Short..... Live it with Positive Attitude...

  6. #6
    Super Contributor
    Join Date
    Mar 2004
    Location
    Singapore
    Posts
    9,968

    Re: Problem in Reading a file using RFileReadStream

    can you show us how you create the Stream etc.

  7. #7
    Regular Contributor
    Join Date
    May 2007
    Posts
    320

    Re: Problem in Reading a file using RFileReadStream

    Quote Originally Posted by skumar_rao View Post
    can you show us how you create the Stream etc.
    Code:
    void CMyAppAppUi::ReadDataFromFile(const TDes& rFileName,TDes& rData) 
    	{
    	RFs fsSession;
    	RFile rFile;
    	
    	// Connects a client process to the fileserver
    	User::LeaveIfError(fsSession.Connect());
    	CleanupClosePushL(fsSession);
    	
    	//Open file where the stream text is
    	TInt err = rFile.Open(fsSession,rFileName, EFileStreamText);//EFileShareReadersOnly));// EFileStreamText));
    	if(err == KErrNone)
    	   {	
    	    CleanupClosePushL(rFile);
    	
        	// copy stream from file to RFileStream object
    	    RFileReadStream inputFileStream(rFile);
    	    CleanupClosePushL(inputFileStream);
    	
    	    //inputFileStream>>rData;
    	    //TInt err;
    	    inputFileStream.ReadL(rData);
    	    
    	// Pop loaded resources from the cleanup stack
    	    	
    	     CleanupStack::PopAndDestroy(2); //  inputFileStream, rFile
    	    	
    	   }
    	else
    		{
    		}
    	CleanupStack::PopAndDestroy();    // fsSession
    		}
    This is my code. Using this code I am reading 2 different files. Please tell me why this error is coming? because first file gets read properly....On second file it gives me error & application crashes....
    Life is Short..... Live it with Positive Attitude...

  8. #8
    Super Contributor
    Join Date
    Mar 2004
    Location
    Singapore
    Posts
    9,968

    Re: Problem in Reading a file using RFileReadStream

    Try the modified code below

    Code:
    void CMyAppAppUi::ReadDataFromFile(const TDes& rFileName,TDes& rData) 
    	{
    	RFs fsSession;
    	RFile rFile;
    	TInt fLength = 0;
    	// Connects a client process to the fileserver
    	User::LeaveIfError(fsSession.Connect());
    	CleanupClosePushL(fsSession);
    	
    	//Open file where the stream text is
    	TInt err = rFile.Open(fsSession,rFileName, EFileStreamText);//EFileShareReadersOnly));// EFileStreamText));
    	
    	if(err == KErrNone)
    	   {	
    		CleanupClosePushL(rFile);
    		fLength = rFile.Size();
    		// copy stream from file to RFileStream object
    		RFileReadStream inputFileStream(rFile);
    		CleanupClosePushL(inputFileStream);
    
    		//inputFileStream>>rData;
    		//TInt err;
    		inputFileStream.ReadL(rData, fLength);
    
    		// Pop loaded resources from the cleanup stack
    		CleanupStack::PopAndDestroy(2); //  inputFileStream, rFile
    	    	
    	   }
    	else
    		{
    		}
    	CleanupStack::PopAndDestroy();    // fsSession
    	}

  9. #9
    Registered User
    Join Date
    Oct 2007
    Posts
    24

    Re: Problem in Reading a file using RFileReadStream

    are you using RFileWriteStream to create the files?
    Last edited by NumptyAlert; 2007-10-24 at 12:54.

  10. #10
    Regular Contributor
    Join Date
    May 2007
    Posts
    320

    Re: Problem in Reading a file using RFileReadStream

    Quote Originally Posted by skumar_rao View Post
    Try the modified code below

    Code:
    void CMyAppAppUi::ReadDataFromFile(const TDes& rFileName,TDes& rData) 
    	{
    	RFs fsSession;
    	RFile rFile;
    	TInt fLength = 0;
    	// Connects a client process to the fileserver
    	User::LeaveIfError(fsSession.Connect());
    	CleanupClosePushL(fsSession);
    	
    	//Open file where the stream text is
    	TInt err = rFile.Open(fsSession,rFileName, EFileStreamText);//EFileShareReadersOnly));// EFileStreamText));
    	
    	if(err == KErrNone)
    	   {	
    		CleanupClosePushL(rFile);
    		fLength = rFile.Size();
    		// copy stream from file to RFileStream object
    		RFileReadStream inputFileStream(rFile);
    		CleanupClosePushL(inputFileStream);
    
    		//inputFileStream>>rData;
    		//TInt err;
    		inputFileStream.ReadL(rData, fLength);
    
    		// Pop loaded resources from the cleanup stack
    		CleanupStack::PopAndDestroy(2); //  inputFileStream, rFile
    	    	
    	   }
    	else
    		{
    		}
    	CleanupStack::PopAndDestroy();    // fsSession
    	}
    Thnx SKumar I resolved that error now. But now I am getting USER 11 error. I am using mid function for reading the file of an item. Could you please tell me, how to remove this error.. I think this is because of mismatching of TBuf8 & TBuf....
    Life is Short..... Live it with Positive Attitude...

  11. #11
    Super Contributor
    Join Date
    Mar 2004
    Location
    Singapore
    Posts
    9,968

    Re: Problem in Reading a file using RFileReadStream

    On which Line you are getting the Error ?

  12. #12
    Regular Contributor
    Join Date
    May 2007
    Posts
    320

    Re: Problem in Reading a file using RFileReadStream

    Quote Originally Posted by NumptyAlert View Post
    are you using RFileWriteStream to create the files?
    yes I am using RFileWriteStream.
    Life is Short..... Live it with Positive Attitude...

  13. #13
    Registered User
    Join Date
    Oct 2007
    Posts
    2

    sorry i posted her dunno where to post this/

    by surfing the internet i found this site that is promoting n95 8gb with wrong specs, by comparing the n95 8gb with the iphone as there 's no wifi/wlan in n95 8gb.aand there's other wrong specs checkem or stop em ..thanks

    http://www.esato.com/phones/index.php/phone=295,cp=302

    thanks
    an N95 user,

  14. #14
    Super Contributor
    Join Date
    Mar 2004
    Location
    Singapore
    Posts
    9,968

    Re: sorry i posted her dunno where to post this/

    Quote Originally Posted by acedeejay View Post
    by surfing the internet i found this site that is promoting n95 8gb with wrong specs, by comparing the n95 8gb with the iphone as there 's no wifi/wlan in n95 8gb.aand there's other wrong specs checkem or stop em ..thanks

    http://www.esato.com/phones/index.php/phone=295,cp=302

    thanks
    an N95 user,
    Mr acedeejay, it is not a good place to Post this thing, Try Putting it http://discussion.forum.nokia.com/fo...play.php?f=157...

  15. #15
    Nokia Developer Champion
    Join Date
    Mar 2006
    Location
    Helsinki, Finland
    Posts
    8,347

    Exclamation Re: sorry i posted her dunno where to post this/

    Quote Originally Posted by acedeejay View Post
    by surfing the internet i found this site that is promoting n95 8gb with wrong specs, by comparing the n95 8gb with the iphone as there 's no wifi/wlan in n95 8gb.aand there's other wrong specs checkem or stop em ..thanks

    http://www.esato.com/phones/index.php/phone=295,cp=302

    thanks
    an N95 user,
    You have certainly posted at wrong place.

    You might post it on Forum Lounge. General Discussion.

    Next time please post your queries on appropriate section.

    Kiran.

Similar Threads

  1. File Browsing Problem
    By Marwa in forum Mobile Java Networking & Messaging & Security
    Replies: 13
    Last Post: 2007-10-10, 15:52
  2. 9500 downloading jad file problem - urgent!!
    By knmehta in forum Mobile Java General
    Replies: 1
    Last Post: 2005-12-13, 09:33
  3. Common problem: wrong file format "exception"
    By lukaszpl in forum Mobile Java General
    Replies: 0
    Last Post: 2005-12-05, 17:09

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×