I have a class FileRecord
and the class public class ZippedFileRecord : FileRecord
, that get stored in SortedList mFiles
which has all the FileRecords and ZippedFileRecords. The issue I'm running into is that I need a way to differentiate between the two, each ZippedFileRecord has a FileRecord and a method called GetFileRecord() where it unzips the file associated with ZippedFileRecord and makes a FileRecord for it (as seen in the chunk below..)
public class ZippedFileRecord : FileRecord
{
FileInfo zipFileInfo; //FileName, FileCreationTime/Date
public FileRecord myRecord = null;
public FileRecord GetFileRecord()
{
if (myRecord == null)
{
//unzip and overwrite FileRecord
UnZipFile();
//return myRecord
return myRecord;
}
else return myRecord;
}
...
...
}
now the portion of code that uses these FileRecords and ZippedFileRecords is something that a user can grab all the FileRecords in a certian date range, and get the info for those displayed on screen. Since ZippedFileRecords are representative of Zipped Files they must first be unzipped. here is the portion of code used to seek out the files to be displayed:
public GetFrames(DateTime desiredStartTime, DateTime desiredEndTime)
{
for(int fileIdx = mFiles.Values.Count-1; fileIdx >= 0; --fileIdx)
{
FileRecord rec = (FileRecord)mFiles.GetByIndex(fileIdx);
if(rec.StartTime>= desiredStartTime && rec.EndTime<=desiredEndTime)
{
...
}
else
{
...
}
}
}
The Line that is causing me issues is FileRecord rec = (FileRecord)mFiles.GetByIndex(fileIdx);
is there any way for me to check weather the mFiles[fileIdx] is a ZippedFileRecord or a FileRecord? because If I can do that I can unzip only as needed instead of unzipping and then rezipping potentially hundreds of Files every time they are to display on screen only to have one or two actually fit in the user's date range