Living .NET...

Musings on .NET, and the like - Manoj G [MVP, Connected Systems Developer]

November 2003 - Posts

Simple Tip: Enumerating Files in a folder

Asked how to enumerate files in a folder, VB6 folks would emphatically say Dir function. Though Dir and other VB6 functions like Mid, Split etc are still supported in .NET through the Microsoft.VisualBasic namespace, they should ideally not be used as they are not supported on the Compact framework. So, the DirectoryInfo class has to be used instead. Here's how:

Dim dir As New DirectoryInfo("<>")
Dim file As FileInfo

For Each file In dir.GetFiles
    
'Do something with the fileinfo object
Next
Posted: Nov 27 2003, 09:15 AM by Manoj G | with no comments
Filed under:
ViewState (De)mystification

In about of a year of .NET development, I had somehow stayed away from the nitty-gritties of ASP.NET. Today, out of the blue, I got this urge to create a custom composite control. After an inevitable struggle, I did manage to do what I wanted to. In the process, I came to know that my knowledge of ViewState was incomplete (crappy in other words) and later got enlightened by this brilliant article written by Paul Wilson, an ASP.NET MVP: ViewState: All You Wanted to Know.

Here's what I understand (in brief): ViewState would contain only that information/properties about controls that are lost after the page is dispatched to the browser. That is, those properties that are not available when post back happens. For example, formatting and style information etc. With this thought in mind, I browsed through the properties of  (System.Web.UI.WebControls) TextBox control using Reflector, and I was surprised to see that the Text property was stored in ViewState too. I wondered why. Text is a property that does not need to be stored in ViewState as this is available through the Form collection and the value will be replaced with the Form value when Postback data is processed before the Load Event.

If someone knows why, please do let me know!!

 
Posted: Nov 21 2003, 07:23 PM by Manoj G | with 3 comment(s)
Filed under: