Written in 2008


In summary, the following samples are included
Name Lang. Format Features Background threading method
PutGuiVb2 VB.NET WinForms PUT BackgroundWorker
VbPutSample VB.NET Command-line PUT None
FolderExplorer2 VB.NET WinForms Explorer style; FolderListings, GET BackgroundWorker
GetFirstListedFile VB.NET Command-line FolderListings, GET None
PutGUI C# WinForms PUT delegate.BeginInvoke and progress decorator Stream
PutCmdline C# Command-line PUT None
GetFolderListings C# Console FolderListings, GET, PUT. None


For VB.NET four samples are included. The VbPutSample is a simple command-line Put client, PutGuiVb2 is a simple GUI Put client, GetFirstListedFile is a command-line program that will walk through the peer’s folders and download the first file it finds listed, finally FolderExplorer2 is a GUI Windows Explorer style application that lists the folders and files on the peer allow the user to navigate through them. In a previous release the Visual Basic samples were created and built by hand, now the samples have been created with Visual Studio with the forms created in the Forms Designer etc.

Screenshot of FolderExplorerVb sample

Both PutGuiVb2 and FolderExplorer2 display a progress bar as they do the upload / download. They use a Background Worker component in which the content is manually copied from the source to the destination stream, in the former application, from the file stream to the ObexPutStream, and in the latter from the ObexGetStream to the list boxes. Each time round they update the progress status, and check for user cancelling.

The Length of the object in the GET operation is accessed through the headers in the ObexGetStream’s new ResponseHeaders property, and is used to calculate the percentage-completed progress there. However the inclusion of such a header is optional and thus if the server has not provided a Length header then a pseudo-progress bar is displayed.


For C#, two PUT clients are included, one Windows Forms and one command-line. The command-line application prints usage information when run with no command-line arguments. The UI client shows asynchronous usage, and progress bar updating as the transfer proceeds. It uses the rather complex method of using delegate’s BeginInvoke feature, along with a ‘decorator’ stream to measure the progress of the download, with a Timer component using its result to update a progress bar.

Screenshot of PutGUI sample Screenshot of PutCmdline sample

There’s also a console-based menu-driven GET client, which, although it is called ‘GetFolderListing’, supports all Get operations, and can connect to both the ‘Folder-Browsing’ and ‘Inbox’ services. It can display the current folder’s folder listing, displaying its content in a similar layout to the Windows’ DIR command; except of course since the parent-folder item does not define any attributes it cannot display the current folder’s last modified time. It can also do a Put operation.

It saves any downloads to the current folder with a name created from the current operation, for instance a raw folder-listing object (command "L") is saved to a filename of <folderName>.xml, with “Root.xml’ used for the default folder. Note that the download is also currently displayed on the screen as it is received, for binary files the text conversion will fail and the displaying will cease, and continue only to display dots as the download proceeds. Its source code is also now included.

Screenshot of GetFolderListing sample


The source code for all the sample projects is included. To compile them from the command-line one could use the following command (on one line).

C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\MSBuild "Brecham Obex\Samples\Samples.sln" /p:Configuration=Release

Otherwise, the solutions can be loaded in Visual Studio and built there.
The debug configuration of some of the samples includes NUnit tests, so as configured that library is required for debug compilation. To get the build to work, one way would thus be to install the NUnit tool from http://www.nunit.org/, otherwise, the tests are all defined within #if NUNIT ... #endif blocks; and currently only two of the projects contains unit-tests: TransportConnection and GetFolderListings. So you could go to the properties pages of those samples and remove "NUNIT" from the Conditional compilation symbols field in the debug build configurations.

Last edited May 15, 2014 at 6:39 PM by alanjmcf, version 3