×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Sep 2005
    Location
    Espoo, Finland
    Posts
    8

    Writing descriptor to file without length property

    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
    Join Date
    Sep 2005
    Location
    Espoo, Finland
    Posts
    8

    Re: Writing descriptor to file without length property

    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. 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
  •