The acronym CBR stands for Comic Book Reader. Basically a CBR file is a renamed RAR archive file. CBR files are used in comic books and slideshows where the images in the archive need to be accessed sequentially. There are some great CBR reader applications out there such as Comix, CDisplay and Comic Reader X which are used to display the book in the correct order.
My goal is not to re-invent the wheel in creating a reader but rather gain access to the CBR archive so I can categorize these collections appropriately and provide a nice interface for browsing the collection. I have found a great library for reading RAR files which I'm using for this project. Below you can see an example of how I'm extracting the first file in the archive to use in our proof of concept.
private void GenerateCover()
{
this.ErrorMessage = string.Empty;
string path = string.Empty;
Chilkat.Rar rar = new Chilkat.Rar();
bool success = rar.Open(FilePath);
PageCount = (int)rar.NumEntries;
path = Path.GetTempPath();
if (success)
{
Chilkat.RarEntry entry = rar.GetEntryByIndex(0);
if (entry.IsDirectory)
{
entry = rar.GetEntryByIndex(1);
entry.Unrar(path);
}
else
{
if (entry.Filename.IndexOf(".jpg") > -1)
{
entry.Unrar(path);
}
}
CoverPath = Path.Combine(path, entry.Filename);
}
else
{
this.ErrorMessage = "There was an Error: " + rar.LastErrorText;
}
}
You can see the demo application which for now is a CD launcher program that you run on autostart. The application loads, scans the directory, and generates a book style index of the CBR files contained on the disc.
For full details and source code, read my code-project article on the project
