Diversity in Tech and friendly tips from Indians (1 Indian atleast)

Sundar Pichai was announced CEO of Google couple days back and India couldn’t be any prouder (Not that he lives in India, nor he is of Indian nationality any more).

For many it reflected the glimpse of hope that Indians have in the tech industry and for many it reflected the hard work and struggles of an entire generation.

Personally, I think it’s a good time to talk about diversity in tech industry as Indians (who hardly had freedom of speech 60 years back) have made it to the top breaking barriers that would rather seem like a dream a decade or two ago.

So, let’s cut to the chase –

Satya Nadella, Sundar Pichai, Indra Nooyi et al, what do they all have in common?

3

There has been a lot of articles raving about the success stories of Satya Nadella, Sundar Pichai and other CEOs in the past few days, who were born in India, who became the CEOs of some of the biggest corporations in the world in the past decade.

What do they all have in common?

They all came to the US on a non-immigrant visa to get their Master’s degree.

They come from middle class families in India where they hardly had a motorcycle (let alone a car). Their families aren’t any special compared to the families of millions of other Indians in technology (including mine).

Most of our parents were born and raised in villages, who then moved to cities and even did a lot of menial labor. 90% of our parents weren’t Engineers nor knew anything about Engineering and Technology..

How are there so many Indians in tech?

It was 2002 and I was in my 9th grade when my parents bought the first computer. It was a HP machine, that had a black and white monitor and ran Windows 95. We didn’t have a car then. We didn’t have cable TV connection. We had a Solidaire TV which was suffering a slow death. We couldn’t get a dial-up modem because we weren’t able to afford the monthly bill (nor did my parents knew what internet / modem was at that time).

Yes! I was one of the kids and we were one of those families (and so was Sundar's, Satya's and Indra's)

Yes! I was one of those kids and we were one of those families (and so was Sundar’s, Satya’s and Indra’s)

The reason I’m saying this is because, our parents’ generation had this overwhelming desire (you can call it an obsession even) to have their kids become Engineers. Late 90s and early 2Ks were the time when Bill Gates was in Indian newspapers almost everyday some way or the other. Not a single soul at that time would have imagined an Indian to be the CEO of a company like Microsoft (or) Google, let alone working in them.

So, how did Indians move to technology?

Desire to have their kids become engineers is one thing, but to be able to afford an Engineering degree is another. India, as we all know is a country that has caste-system and with over a billion people, affordable college education can be very challenging. But the Reservation System (the affordable system that enhances educational and other opportunities for lower castes) makes it easier for people belonging to lower castes. It makes Engineering and Technology education more affordable and available to communities that are below poverty line and increases diversity in the tech educational institutions and therefore tech workplaces.

About the availability of Engineering education – When I joined college in 2005, there were 190 Engineering colleges in my state (Tamil Nadu) that were affiliated to the State University System. By the time I graduated in 2009, there were over 300. Now there are over 550.

To give you some perspective, Tamil Nadu’s area is only 50,000 sq. miles and there are over 500 Engineering college campuses under the State University system. California is over 160,000 sq. miles and there are only 17 (let’s even say 30) Engineering college campuses that are affiliated to the State University system.

This is the reason why India produces 1.5 million engineers each year, whose surplus get employed in US, Europe etc.

Diversity in tech industry and suggestions to improve diversity

The reason for me to write this post is because, Techcrunch published this article and there has been a debate whether or not advocating diversity at the workplace is right. Even though it is necessary and can be considered right, there has been a lot of debates whether or not advocating workplace diversity (which often seems to be gender and race oriented) is the right way to bring about actual diversity.

Sure, the best person suited for the job is highly important, but the gender, race, religion etc., of the person trying to get employed should in no way influence the chance of them getting the job. If it does, then definitely the employer needs to learn about diversity.

But, this post isn’t targeting that group of people. It targets folks who advocate diversity at workplace and strongly believe that advocating diversity at workplace is best / the only solution. So here goes –

Advocating diversity in workplace (especially in the tech sector) is vital. If the Organization blatantly employs people belonging to a specific race, gender, religion, sexual orientation etc. – advocating diversity would be more than important. In which case, companies like Paradigm would need to be an integral part of the organization. But for a company that isn’t “diverse enough”, say companies like Asana or Google, who acknowledge the need to be more diverse, but aren’t diverse enough according to the standards set by the diversity advocacy groups or the society, advocating diversity isn’t the real solution.

Let’s look at race diversity and compare Indians (who are predominantly temporary visa holders in the US) and African Americans, for example –

According to the US Census Bureau, here is how the population is distributed. For this specific example, let’s look at White, Black and Asian “alone” racial ethnic groups, and classify the rest as others –

USPopulation

Here is the stats for people graduating with a Bachelor’s degree in Science and Engineering (excluding White, as it seems very dominant – more than 60%) provided by the NSF, including Temporary Visa Holders.

Bachelorsdiversity

Here is the same stats for people graduating with a Master’s degree in Science and Engineering including Temporary Visa Holders.

Mastersdiversity

I understand that mixing Visa holders with race makes the stats a little convoluted. Nevertheless, based on the above stats, for every African-American that graduates with a Master’s degree in Science and Engineering, there are 3 temporary residents (people like Sundar Pichai, Satya Nadella etc. including myself, who came to the US on a non-immigrant visa) graduating with a Master’s degree in the same field.

To give you more perspective, there are about 10 million people who come to the US on a non-immigrant visa each year, out of which 700 thousand people come here on student visas (F, F-1 visas etc.). Assuming the 700 thousand constitute to 20% of those who graduate with Master’s degree in Science and Engineering, there are about 250,000 African Americans graduating with a Master’s degree all over US (which is roughly about 0.6% of the African-American population in the United States).

The reason I think diversity in tech-sector is a more systemic problem (based on the above race example) is because, for every African-American (or any other racial minority group in tech sector) that wants to get employed in the tech sector, there are more temporary visa holders, let alone White Americans that are equally or more qualified to compete with them for that tech-related jobs. Even though, urging the employers to adopt diversity and employ multiple racial ethnic groups is a solution, I don’t think it is the ultimate solution if you’re advocating diversity in the tech sector.

By the way, my point here is not to point out that African-American or any other community as a minority community based on tech education. But, to point out that Engineering & Technology education isn’t the preferred education for many minorities in the tech sector. This is the same reason why you don’t find so many Indians in arts, history, geology or even sports.

Bringing minority racial groups into technology is one thing, but bringing technology to minority racial groups is another.

Here are some of my suggestions, based on the Engineering and Technology scenario in India that I hope will be useful to minority communities / diversity advocators, if they wish to bring more minorities into the tech sector –

  • Engineering and Technology as a culture
    • There is a saying in India – “Become an engineer and then figure out what to do in life”. Even though a lot of Indians are proud with that saying, it is very unhealthy for the current generation of Indians. The reason being, a lot of non-tech related fields have very few to zero resources. For example, classrooms for literature, history, arts classes are nearly empty these days.
    • But the disadvantages of the tech related cultural obsession aside, there are lots of Indians who are excelling in the tech sector thereby contributing significantly to their community and especially to their corresponding middle classes.
    • When there is a growing population of Engineers from a certain community, ethnic group etc., the society will automatically adapt itself for that specific community / ethnic group.
    • To increase the number of engineers in a community, the first step should be taken by the parents in influencing their kids towards a tech education.
  • Making Engineering more available
    • Community Colleges are great, but I’ve always hated the fact that there aren’t places like NIIT, Aptech etc., here in the US.
    • Even though there are many online schools (Khan Academy, Code School, Pluralsight etc.,), a place like KUMON for example, that offers courses on Web Development, System Administration etc., which would eventually help people get certified by Microsoft, Oracle or Cisco would go a long way and make people who want to move to tech-sector from non-tech fields more employable.
  • Making Engineering more affordable
    • I never really understood why prestigious institutions like Stanford, Harvard etc., have such an expensive fee structure, but Community Colleges are highly affordable. Sure, Stanford, Harvard etc., provide financial aids. But shouldn’t it be the other way round?
    • Atleast that’s the way it is in IITs in India and I personally think that could make education (not only Engineering and Tech) more competitive and affordable to everyone.

As President Obama said, the US needs a “Sputnik moment” when it comes to Engineering and Technology, which I personally think should consider diversity and should be all-inclusive (race, gender, religion, sexual orientation etc.).

Anyways, these are my personal thoughts on improving diversity, specifically in the tech sector (which Indians seem to have a good handle of). I could be wrong. Please feel free to drop a comment below with your thoughts.

From a .NET Expert to a Rails Noob

Dear .NET – You’ve been an excellent development platform. Thanks to corporate America, I got to ride business class – not only flights but with your Visual Studio 2012 Ultimate (funny, it actually costs as much as a business class ticket to the other side of the planet!), Sharepoint, TFS and other sweet tools you’ve got to offer. But when it comes to start ups and cool things out there, you’re like getting married to a rich old woman who loves to go shopping every weekend (that’s a terrible comparison, I know!) and it’s hard to turn away from other good tools in the other side of the developer world.

I was introduced to Ruby on Rails recently. Although it was a bit odd initially, coming from a world with ; (semi-colons). It was pretty hard to wrap my head around some of the loosely typed syntax. Nevertheless, I’ve started to realize the full potential (Or atleast 80%) of what Rails can do and would like to explore it to the fullest.

Although there are lots of good resources out there for Rails. I’d like to blog about the teensy-weeny information I was able to gather as part of my ongoing Rails expedition.

To begin with, I started with these resources –

  • Rails for Zombies (http://railsforzombies.org/)
    • Some of us would have seen this guy from the MVC videos from way back when. Gregg Pollack – He is absolutely phenomenal. After a couple of screencasts – I was like “Whaaat?? Did you just cover MVC, CRUD and Queries (LINQ as we call in the .NET world)?? Is it that simple??”
  • CodeSchool (http://www.codeschool.com/)
    • Having gotten through 50% of Rails for Zombies, I automatically got a Pro subscription with CodeSchool (which teaches Rails from the basics with it’s sweet web editor) and has more Gregg Pollack tutorials
  • RailsCasts (http://railscasts.com/)
    • Just when you think you’ve seen it all. You were told about this guy who does these awesome screencasts about the latest on Rails, Javascript libraries and what not. Another Pro subscription!
  • CodeSchool TV (https://www.youtube.com/user/CodeSchoolTV)
    • CodeSchool’s youtube channel FTW!
  • PeepCode (https://peepcode.com/screencasts/ruby-on-rails)
    • I haven’t started this one yet. But I’ve been told it’s pretty good. Definitely something worth checking out.

Having acquired some rogue skills in RoR from these screencasts, I decided to get a book to discipline myself. So I bought this one (which had pretty good reviews) – Ruby on Rails 3: Learn Rails by Example by Michael Hartl. It’s a very nice book where the author takes you through an example of creating a Twitter like site from the scratch. He does it with TDD (Test Driven Development), so that’s a plus (as other resources I’ve looked into didn’t go deep into TDD as this one did).

Having spent almost a month learning and playing with Rails. I decided it’s time to do some code. So I formatted my Windows 8 gaming machine (Alienware M15X) and installed Ubuntu 12.04 (No regrets!).

I got these installed to start with –

  • I followed this article in Smashing Magazine (step by step) and got rails working almost perfectly.
  • Next stop IDE – I’ve used Netbeans before and it looked like Netbeans had some good Rails plugins, so I went straight ahead and grabbed Netbeans with its plugins.
    • I was told Aptana Studio, Eclipse etc are also good IDE’s for Rails
    • While we’re talking about IDE’s – as I explored Rails, I found that IDE’s hardly play a major role. You can almost do everything from the terminal / console. And it’s a lot simpler too.
    • I used a Mac machine for Rails development too. I loved the Sublime text editor – way more than TextMate and other text editors I’ve used in Mac.
  • Having covered the front-end, I wanted to get a good DB environment with a decent toolset (as I will always feel nostalgic without SQL Server). PostGreSQL looked like a pretty good option. I configured it as mentioned in the article and it worked like a charm.
    • Rails comes with SQLite which isn’t too bad too.
  • Having gotten the development environment ready. It was time for source control and code hosting. I went nowhere but GitHub. I followed this article and got my repository setup in seconds.
    • There is a similar hosting application like GitHub called BitBucket – It is really sweet especially if you’re working as a team. Definitely something to checkout.
  • To get fancy – I found that there was a free CI (Continuous Integration) environment for Rails which plugged into GitHub’s public repository for free! Yes – TravisCI
    • Another good CI alternative – CircleCI which helps you plug into private repositories of GitHub
  • Deployment == Heroku == Cloud (9)
    • Heroku is a sweet place to park your app no matter if it’s a Camry or a Lamborghini.

Hopefully, this will help a Rails rookie get started. Happy coding!

Ext JS hack to use Font Awesome as Icon Class

Recently, I created a hack to use the awesome Font Awesome library alongside Ext JS (3.4). The hack I did allows font awesome icons to be served as good Ext JS icons for Tree Panels.

The following is the code –

Ext.sequence(Ext.tree.TreeNode.prototype, 'render', function (treenode) {        
    $('.x-tree-node-icon').removeClass('x-tree-node-icon').replaceWith(function () {
        if (typeof($(this).attr('class')) != 'undefined')
            return '<i class="' + $(this).attr('class') + '"/>';
        else
            $(this).addClass('.x-tree-node-icon');
    });
});    

Ext.intercept(Ext.tree.TreeNode.prototype, 'setIconCls', function (cls) {               
    $($(this)[0].ui.elNode).find('i').removeClass().addClass(cls);
});

After including this javascript at the top level, you can use Font Awesome (3.4) icons by just referencing them in the iconCls. This hack can also be extended for button icons etc.

Here is the link to the github repository – https://github.com/aswinramakrish/ext-js_font-awesome

 

Sharepoint Document Library for Document Management

Document Management could get painful, especially when you are saving documents in your server. Even though storage is cheap, managing documents via Sharepoint could be a neat solution if you are using Sharepoint as some kind of a back end CMS. I did some document management using Sharepoint for one of my projects that I’d like to share. So let’s jump right in.

In order to manage documents, you will have to do these:

  • Have a DTO (a Data Transfer Object –  if necessary) to send the document information (if you are doing AJAX using jQuery or whatever)
  • Document Upload – In order to upload documents, you will need the following methods
    • Check if the folder exists – A method to check if the folder exists
    • Create Folder – Create a folder in the document library (to store documents by an Entity ID)
    • Upload File – Upload documents to a specific folder
  • Document Download – Download the specified document
  • Delete documents

DTO Definition

This is how my DTO looks –

public class MyDTO
{
public string Id { get; set; }            // ID of the document
public string Index { get; set; }         // Index of the document
public string FileName { get; set; }      // File Name
public string FileTypeIcon { get; set; }  // File Type Icon
public string CreatedOn { get; set; }     // Created On
public string FileRef { get; set; }       // Sharepoint File Reference
}

Document Upload

To upload documents, the first method we’ll look at is the CheckIfFileExists method –


/// <summary></pre>
 /// Check if a file / folder exists
 /// </summary>
 /// <param name="FilePath">File Path</param>
 /// <returns></returns>
 public bool CheckFileExists(string FilePath)
 {
 Lists lists = new Lists();
 lists.Url = ConstructServiceUrl("Lists.asmx");  // A custom method to construct Sharepoint URL eg. https://yoursharepointsite.com/_vti_bin/lists.asmx
 lists.Credentials = new System.Net.NetworkCredential("Username", "Password"); // Your Sharepoint credentials

XmlNode nodes;

 // Instantiate an XmlDocument object
 System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();
 System.Xml.XmlElement query = xmlDoc.CreateElement("Query");
 System.Xml.XmlElement viewFields = xmlDoc.CreateElement("ViewFields");
 System.Xml.XmlElement queryOptions = xmlDoc.CreateElement("QueryOptions");

query.InnerXml = "<Where><Gt><FieldRef Name=\"ID\" />" +
 "<Value Type=\"Counter\">0</Value></Gt></Where>";
 viewFields.InnerXml = "<FieldRef Name=\"Title\" /><FieldRef Name=\"Description\" />";
 queryOptions.InnerXml = "<ViewAttributes Scope=\"RecursiveAll\"/>";

nodes = lists.GetListItems("UploadList", null, query, viewFields, "5", queryOptions, null); // Get List Items from the Sharepoint List Library "UploadList"

foreach (System.Xml.XmlNode node in nodes)
 {
 if (node.Name == "rs:data")
 {
 int index = 1;
 for (int i = 0; i < node.ChildNodes.Count; i++)
 {
 if (node.ChildNodes[i].Name == "z:row")
 {
 if (node.ChildNodes[i].Attributes["ows_FileRef"].Value.Split('#')[1] == FilePath)
 {
 return true;
 }
 }
 }
 }
 }
 return false;
 }
<pre>

Next, we want to create a folder to save all the documents.

</pre>
/// <summary>
 /// Creates Folder
 /// </summary>
 /// <param name="FolderPath">Folder Path</param>
 /// <returns></returns>
 public bool CreateFolder(string FolderPath)
 {
 Dws dws = new Dws();
 dws.Url = ConstructServiceUrl("Dws.asmx");  // Custom method to construct the web service URL eg: https://yoursharepointsite.com/_vti_bin/dws.asmx
 dws.Credentials = new System.Net.NetworkCredential("Username", "Password");

if (!CheckFileExists(FolderPath))
 {
 dws.CreateFolder(FolderPath);
 return true;
 }
 else
 {
 return false;
 }
 }
<pre>

Simple Isolated Storage Exploitation

Isolated Storage is nothing but a storage location in a user’s local filesystem where an application can store data. The Isolated Storage is generally exploited by web applications to store information of any kind (say application data, user data, session state etc) . The initial quota for an application is 1MB, which could be modified later by the application. The maximum limit depends on the operating system and the hard disk space.

The Isolated Storage data in Windows 7 is located in:

C:\Users\<User Profile>\AppData\Local\IsolatedStorage

 In order to use Isolated Storage in a simple Silverlight Application, consider the following steps.

  • Add the Isolated Storage library,

using System.IO.IsolatedStorage;

  • Now, we need to create a file in the Isolated Storage for storing the data, so we need to instantiate IsolatedStorageFile class and inform the application to store data in the next available memory compartment.
  • Having done that, we will need to write data into that file, so we need to instantiate IsolatedStorageFileStream class with the filename, file mode and and the IsolatedStorageFile instantiation.

Consider the following code as an example:

using System.IO.IsolatedStorage;                    // Step 1

private void SaveUserData(string UserName, string Pwd, int UserNumber)

{

var file = new XDocument(

new XElement("UserNum", UserNumber,

new XElement("UserName", UserName),

new XElement("Password", Pwd))

);

using(IsolatedStorageFile isf = new IsolatedStorageFile.GetUSerStoreForApplication())            // Step2

{

IsolatedStorageFileStream isfs=new IsolatedStorageFileStream("File1", FileMode.Append, isf);          // Step 3

file.Save(isfs);

}

}

In the above code, the GetUserStoreForApplication() method gets the next available storage location available for the application. In order to store data for the entire site, the GetUserStoreForSite() method can be used.  

The above code stores the following as a file in the isolated storage.

<UserNum>1</UserNum>

<UserName>Sample User</UserName>

<Pwd>Sample Pwd</Pwd>

Though the quota is fixed for an application initailly, it can be changed by the developer. To do that the following method is used.


long a = 2048000;

isf.IncreaseQuotaTo(a);

This increases the quota for the application to 2MB.

In order to view the quotas of different silverlight applications do the following:

  • Right click the Silverlight Application and select “Silverlight”.
  • Go to “Application Storage” and you would see somthing like this.

Advantage

  • By using the isolated storage, the application can store more data and have a better control of the stored data.
  • The data stored in localized to the user’s system.
  • 

Disadvantage

  • It gets difficult to use in applications which needs to run with lower privileges.

Nested Data Binding – Silverlight

One of the major features of Silverlight, which saves the developer a lot of coding time is DataBinding, where you can bind a UserControl to data or a collection of data. If you are still wondering how DataBinding saves time, here is an example. Consider a tree of depth say 1000. Instead of adding 1000 TreeViewItems manually, you can write few lines of code to bind your TreeView to a Collection.
I would like to add this basic example for binding a TreeView to a data source. I will also be using nested binding, wherein a DataTemplate uses another DataTemplate as ItemTemplate.
Its a best practice to add the Template (DataTemplate or HierarchicalDataTemplate) to any UserControl’s Resource which is at a higher level and at a scope of visibility to the desired control. This facilitates code re-usability by the child controls.
As an example I created this sample application, where a HierarchicalDataTemplate uses another HierarchicalDataTemplate as ItemTemplate. The simplest example I could think of was a collection of Files and Folders.

Though the idea was something like an Folder Explorer. I used a simple File and Folder collection just to show the nested binding. To make the application look like a Folder Explorer, I created a Grid with two columns containing a TreeView on the left pane and a ListBox on the right pane.

Having created controls which can contain Items, I create two HierarchicalDataTemplates; one for files and the other for the folders. To keep it simple, I use a StackPanel which holds an Image and a TextBlock which has the File / Folder’s name as its Text.

Something like this.


<common:HierarchicalDataTemplate x:Name="template2">
<StackPanel Orientation="Horizontal">
<Image x:Name="imgTemplate2" Source="Images/file-icon.png" Height="15" Width="15"></Image>
<TextBlock x:Name="txtTemplate2" Text="{Binding FileName}"></TextBlock>
</StackPanel>
</common:HierarchicalDataTemplate>
<common:HierarchicalDataTemplate x:Name="template1" ItemTemplate="{StaticResource template2}"
ItemsSource="{Binding Files}">
<StackPanel Orientation="Horizontal">
<Image x:Name="imgTemplate1" Source="Images/Open-Folder-icon.png" Height="15" Width="15">
</Image>
<TextBlock x:Name="txtTemplate1" Text="{Binding FolderName}"></TextBlock>
</StackPanel>
</common:HierarchicalDataTemplate>

Having created the HierarchicalDataTemplates for the Files and Folders which can be used as ItemsSource for TreeView, we create a HierarchicalDataTemplate for the ListBox.


<common:HierarchicalDataTemplate x:Name="template3">
<StackPanel Orientation="Horizontal">
<Image x:Name="imgTemplate3" Source="Images/file-icon.png" Height="25" Width="25"></Image>
<Text
Block x:Name="txtTemplate3" Text="{Binding FileName}"></TextBlock>
</StackPanel>
</common:HierarchicalDataTemplate>

After creating all the HierarchicalDataTemplates, we can now createthe  TreeView and ListBox and ItemsSource them to their respective HierarchicalDataTemplates

<controls:TreeView x:Name="TreeBind" ItemTemplate="{StaticResource template1}"
ItemsSource="{Binding Folders}"
SelectedItemChanged="TreeBind_SelectedItemChanged">
</controls:TreeView>
<ListBox x:Name="lstRight" Grid.Column="1" ItemTemplate="{StaticResource template3}"
ItemsSource="{Binding Folders}"
SelectionChanged="lstRight_SelectionChanged"></ListBox>

One which holds the File information and the other which holds Folder information.

public class FileInfo
{
/// <summary>
/// File Name
/// </summary>
private string _fileName;

public string FileName
{
get { return _fileName; }
set
{
if (_fileName != value)
_fileName = value;
}
}
}
public class FolderInfo
{
/// <summary>
/// FolderName
/// </summary>
private string _folderName;

public string FolderName
{
get { return _folderName; }
set
{
if (_folderName != value)
_folderName = value;
}
}

/// <summary>
/// Collection of Files inside a Folder
/// </summary>
public ObservableCollection<FileInfo> Files { get; set; }

}  After this, I create a simple method to populate the TreeView on the left pane.
/// <summary>
/// A method to populate the TreeView
/// </summary>
private void PopulateTreeView()
{
for (int i = 0; i < 10; i++)
files.Add(new FileInfo() { FileName = "File" + i });

for (int i = 0; i < 10; i++)
{
Folders.Add(new FolderInfo()
{
FolderName = "Folder" + i,
Files = files
});
}

TreeBind.ItemsSource = Folders;
}

I also create the SelectedItemChanged event for the TreeView and ListBox to make the application look like a simple Folder Explorer.


/// <summary>
/// LstRight SelectionChanged Event
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void lstRight_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
FileInfo file = (FileInfo)lstRight.SelectedItem;
MessageBox.Show("You selected " + file.FileName, "Sample MessageBox", MessageBoxButton.OK);
}

/// <summary>
/// TreeBind SelectedItemChanged Event
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void TreeBind_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
{
Type tSelectedItem = TreeBind.SelectedItem.GetType();
Type tFolders = typeof(FolderInfo);
Type tFiles = typeof(FileInfo);

if (tSelectedItem == tFolders)
{
FolderInfo folder = (FolderInfo)TreeBind.SelectedItem;

lstRight.ItemsSource = folder.Files;
}

if (tSelectedItem == tFiles)
{
FileInfo file = (FileInfo) TreeBind.SelectedItem;
MessageBox.Show("You selected " + file.FileName,"Sample MessageBox",MessageBoxButton.OK);
}
}

Hope this application gives a flavor of Folder Explorer which can be used in different scenarios.   Here are few screenshots of the application.

– Aswin Ramakrishnan