How to find folder id for existing smartsheet

All,

I am trying to create and maintain a bunch of smartsheets using the API. I would like to find an existing smartsheet to use as a template and create new smartsheets based on the source sheet and in the same folder as the source sheet.

I have code to locate the source smartsheet as shown below. I can find the sheet no problem, however, the folderID of the found sheet is null. How can I locate the folder the sheet that I found is located in?

Here is the code to find the existing smartsheet. Is there a way to find the folder of this sheet?

        // Get all the sheets this user can see...
        PaginatedResult<Sheet> sheets = smartsheetClient.SheetResources.ListSheets( 
          new List<SheetInclusion> { SheetInclusion.SHEET_VERSION }, 
          new PaginationParameters( true, null,null ), null );
        log.Debug( "Found " + sheets.TotalCount + " sheets" );

        // Loop through all the sheets and find the matching passed in sheet name
        int sheetIndex = 0;
        while( sheetIndex < sheets.TotalCount )
        {
          long aSheetID = (long)sheets.Data[sheetIndex].Id;
          aSheet = smartsheetClient.SheetResources.GetSheet( aSheetID, null, null, null, null, null, null, null );
          log.Debug( "Processing Sheet: " + aSheet.Name + " - " + aSheet.GetType() );
          if( aSheet.Name.Equals( aSheetNameToLocate, StringComparison.OrdinalIgnoreCase ) )
          {
            log.Debug( "Found Sheet: " + aSheet.Name + " - " + aSheet.GetType() );
            foundSheet = true;
            break;
          }
          sheetIndex++;
        }

Answers