Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User toshaga's Avatar
    Join Date
    Sep 2005
    Location
    Espoo, Finland
    Posts
    8
    Hi,

    I am using SDK 3rd Edition MR and Carbide.c++. I need to write a string to file and I am working with the Hello World example. Unfortunately, when I put a descriptor in the output stream to the file, both the descriptor's data and lenght are written. Then the length property is interpreted as character which I do not need. How can I only write the string held by the descriptor? Here's the source:

    Code:
    // Create a file to write the text to
    			RFs fsSession;
    			User::LeaveIfError(fsSession.Connect());
    			CleanupClosePushL( fsSession );
    			_LIT(KText, "Text");
    
    			TInt err = fsSession.MkDirAll(KFileName);
    			if ( (KErrNone != err) && (KErrAlreadyExists != err) )
    			{
    				CleanupStack::PopAndDestroy(1); //  fsSession
    				return;
    			}
    	
    			RFile file;
    			err = file.Replace(fsSession, KFileName, EFileWrite );
    			CleanupClosePushL( file );
    			if ( KErrNone != err )
    			{
    				CleanupStack::PopAndDestroy(2); // file, fsSession
    				return;
    			}
    				
    			RFileWriteStream outputFileStream( file );
    			CleanupClosePushL( outputFileStream );
    			outputFileStream << KText;
    		
    			CleanupStack::PopAndDestroy(3); // outputFileStream, file, fsSession
    I'll appreciate any help!

    Regards,
    Todor

  2. #2
    Registered User toshaga's Avatar
    Join Date
    Sep 2005
    Location
    Espoo, Finland
    Posts
    8
    Solved it One should always look first into the help of the SDK rather than internet... Here it is if anyone experiences the same problem.
    Code:
    		        RFs fsSession;
    	                User::LeaveIfError(fsSession.Connect());
    			CleanupClosePushL( fsSession );
    			_LIT8(KText, "Text"); //note it is explicitely _LIT8 not _LIT
    
    
    			TInt err = fsSession.MkDirAll(KFileName);
    			if ( (KErrNone != err) && (KErrAlreadyExists != err) )
    			{
    				CleanupStack::PopAndDestroy(1); //  fsSession
    				return;
    			}
    	
    			RFile file;
    			err = file.Replace(fsSession, KFileName, EFileWrite );
    			CleanupClosePushL( file );
    			if ( KErrNone != err )
    			{
    				CleanupStack::PopAndDestroy(2); // file, fsSession
    				return;
    			}
    				
    			file.Write(KText); // Forget about streams, just write:)
    	
    			CleanupStack::PopAndDestroy(2); // outputFileStream, file, fsSession
    Regards,
    Todor

Similar Threads

  1. ****Data writing on a text file in the mobile********
    By amit.das1980 in forum Mobile Java General
    Replies: 2
    Last Post: 2006-01-19, 22:19
  2. Tips on using NDS 1.1
    By mitts in forum Symbian Tools & SDKs
    Replies: 7
    Last Post: 2006-01-18, 16:07
  3. Replies: 1
    Last Post: 2005-05-26, 14:22
  4. Help !about .mbm的形成
    By wangguoshui in forum Symbian
    Replies: 4
    Last Post: 2004-12-23, 03:37
  5. Replies: 0
    Last Post: 2002-06-10, 12:24

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved