×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Regular Contributor
    Join Date
    Jul 2009
    Posts
    211

    Question Reading the name of all image files in a folder

    Hi I am using the following code to browse throgh the folders.


    void CBitmapAppUi::BrowseUsingAknSelectionDlg(const TFileName& aPath)
    {
    filename.Append(PathInfo::PhoneMemoryRootPath());


    _LIT(KDialogTitle, "Browse files");
    TBool ret = CAknFileSelectionDialog::RunDlgLD(filename,PathInfo::PhoneMemoryRootPath(),KDialogTitle,NULL);

    // "ret" is true, if user has selected a file
    if( ret)
    {
    _LIT(KQueryStr, "Open file");
    TBool retval=CEikonEnv::QueryWinL(KQueryStr,filename);
    if(retval)
    Convert(filename);//Function to convert selctd file into mbm format to draw it in screen

    }
    else
    {
    CEikonEnv::Static()->InfoWinL(_L("Select Image"),_L(""));
    }
    }



    If the user selects a image in a folder(EX:C:\Data\Images\Pictures\winter.jpg),I want to read the name of all image files in the same folder and want to open it one by one(similar to slideshow).

    How to do that?Please help me.
    Thanks.

  2. #2
    Registered User
    Join Date
    May 2007
    Location
    Poland
    Posts
    606

    Re: Reading the name of all image files in a folder

    Hello,
    for getting file list name you could use:
    Code:
    TInt GetFilesFromFolderL(const TDesC& aFolder,
    		CDesCArray* aArray, TUint aEntrySortKey)
    	{
    	CDir* File_list = NULL;
    
    	while (iFilesArray->Count()> 0)
    		{
    		iFilesArray->Delete(0);
    		iFilesArray->Compress();
    		}
    	TInt err = 0;
    	err=iFs.GetDir(aFolder, KEntryAttNormal, ESortByName,
    			File_list);
    	if(err!=KErrNone)
    		{
    		if(File_list)
    			{
    			delete File_list;
    			File_list = NULL;
    			}
    		return err;
    		}
    	if (File_list)
    		{
    		File_list->Sort(aEntrySortKey);//ESortByName|EDescending
    
    		for (TInt i = File_list->Count() - 1; i >= 0; i = i - 1)
    			{
    			if (!File_list->Count() || (*File_list)[i].IsSystem()
    					|| (*File_list)[i].IsHidden() || (*File_list)[i].IsDir())
    				{
    				// ignore System & Hidden Files & folders
    				}
    			else
    				{
    				aArray->AppendL((*File_list)[i].iName);
    				}
    			}
    		}
    
    	delete File_list;
    	File_list = NULL;
    	return err;
    	}
    calling:
    Code:
    GetFilesFromFolderL(KFolderName, iFilesArray, ESortByName);
    While you have it you can check extensions of the files and remove thoes which are not images.


    ps.
    for selecting image from device you could use MGFetch:
    Code:
    CDesCArray * iArray;
    iArray = new (ELeave) CDesCArrayFlat(1);
    if (MGFetch::RunL(*iArray, EAnyMediaFile, EFalse))
    	{
        TFileName fileName;
        fileName.Copy((*iArray)[0]);
    if(iArray)
    {
    delete iArray;
    iArray=NULL;
    }
    good luck
    Nuker85

  3. #3
    Regular Contributor
    Join Date
    Jul 2009
    Posts
    211

    Re: Reading the name of all image files in a folder

    Hi Nuker,

    Before calling ur GetFilesFromFolderL(KFolderName, iFilesArray, ESortByName);
    user have to select to folder.

    How to allow the user to select the folder?//sample code

  4. #4
    Registered User
    Join Date
    May 2007
    Location
    Poland
    Posts
    606

    Re: Reading the name of all image files in a folder

    Hello,
    check SDK and search for RFs GetDir
    Code:
    err=iFs.GetDir(aFolder, KEntryAttNormal, ESortByName,
    			File_list);
    from sdk:
    /**
    @publishedAll
    @released

    File/directory attribute: a directory without the hidden or system attribute.
    */
    const TUint KEntryAttDir=0x0010;
    changing
    Code:
    KEntryAttNormal
    you can select what do you want to display.
    You could start with c:\\ drive and display its folders for example in listbox and if user select any of its items just refresh list
    Code:
    (( *FilesArray ) [ iListBox->View()->CurrentItemIndex()])
    appended to "c:\\" and display thoes path folders

    good luck

Similar Threads

  1. Replies: 5
    Last Post: 2007-09-25, 08:12
  2. HELP: Mutable Image to Immutable Image?
    By rj_cybersilver in forum Mobile Java Media (Graphics & Sounds)
    Replies: 1
    Last Post: 2005-03-26, 09:58
  3. Replies: 0
    Last Post: 2003-10-14, 04:37
  4. Storing Audio/ image files as byte arrays in flat files(eg. bin files)
    By anantharaj1999 in forum Mobile Java General
    Replies: 0
    Last Post: 2003-06-09, 11:57
  5. Loading Image data from 'raw' bytes
    By LongSteve in forum Mobile Java General
    Replies: 2
    Last Post: 2002-11-20, 17:38

Posting Permissions

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