I like the idea of tracking how many times files have been downloaded from the site. There is a sence of achievement as you see the count increase over a period of time.
Over the past couple of years I have come across a few good file download extensions written for blogengine.
Al Nyveldt – SimpleDownloadCounter
Ruslan Tur – DownloadCounter
Chris Blakenship - FileDownloadCounter
The extension by Chris has been installed on my site for the last year or two and it has worked very well. I have recently come to a point where I need, or rather want, more features than the extension provides. I had two options, to write my own from scratch, or enhance an already written extension to include the features I require. I decided stick with the filedownloadcounter by Chris Blakenship as it was already integrated in to the site and it would be a good foundation to start from.
The features I decided to build into to extension are:
- Record the date the file was last downloaded.
- The ability to add a description for the file.
- The ability to assign the file to a category e.g. theme, extension, application.
- When a file is uploaded it goes into a sub folder off of the standard files folder. The sub folder is constructed from the current year and month, e.g. yourdomain.com/files/2010/5. I wanted a way to record this location for each file.
To accomodate for these changes the xml file structure has chanded:
1: <?xml version="1.0" encoding="utf-8" standalone="yes"?>
2: <files>
3: <file name="archive.zip"
4: path="2008/3/archive.zip" dateadded="03/03/2008 18:33:30"
5: description="This extension displays a random quote."
6: lastdownload="5/31/2010 5:37:28 PM"
7: category="Blogengine Extensions"
8: ipaddress="10.10.10.10">
9: 207
10: </file>
11: </files>
Installation
- Copy the files from admin-pages folder to your site admin/pages folder.
- Copy the files from app_code-controls folder to your site app_code/controls folder.
- Copy the files from app_code-extensions folder to our site app_code/extensions folder.
- Copy the usercontrol from the user controls folder to your site User Controls folder.
The admin page allows you to edit the the description and the category, the latter not being case sensitive. The admin page also has a file upload facility with an option where you can choose whether or not to create an entry in the xml file.
Dislpaying the Download Count
There are two ways to display the download count. This is the first way;
1: <div class="box">
2: <h1>File Downloads</h1>
3: <blog:DownloadedFileStats ID="DownloadedFileStats" runat="server" />
4: </div>
The second way is to use the usercontrol in a blogengine page, standard aspx page or similar by usercontrol injection.
NOTE: do not include any spces.
[ usercontrol: ~/user controls/downloadedfilestats.ascx ]
the results are displayed in a table which has classes assigned to its elements for styling.
CountFileDownloadsTable - table level
CountFileDownloadsTableTH - Table header
CountFileDownloadsTableTR - Table row
CountFileDownloadsTableTD - Table data
CountFileDownloadsTableCategory - Category row
as I have done here;

The Download File Counter can be downloaded from here DownloadedFileCounter.zip (10.07 kb)
and my download page.