Blog on software engineering


Using quotes in XML

To use quotes in xml, use “"

<exec program="CMD.EXE"
              commandline="/C &quot;${installPath}\DatabaseInstallation.cmd&quot;"
            <arg value="${Database_DataSource}" />

GetFiles, sorted by Creation DateTime, filtered by include file mask and exclude file mask, including subfolders in C#

The “GetFiles” function, returns all files in the given folder, including subfolders, that match the “includeMask”. The result is sorted by the file CreationTime. The function excludes all files that match the “excludeMask”


To call the function:

List<FileInfo> files = FileSystemHelper.GetFiles(@"C:\Windows","*.*", "*.exe", SortOrder.Ascending, SearchOption.AllDirectories);


The function:
/// <summary>
Get files in a folder sorted by creation datetime and filtered by include mask and exclude mask
/// </summary>
/// <param name=”folder”>
The folder containing the files</param>
/// <param name=”includeMask”>
Include files that meet the given mask</param>
/// <param name=”excludeMask”>
Exclude files that meet the given mask</param>
/// <param name=”sortOrder”>
Sort order, ascending or descending</param>
/// <param name=”searchOption”>
AllDirectories or TopDirectoryOnly</param>
/// <returns></returns>
public staticList<FileInfo> GetFiles(string folder, string includeMask, string excludeMask, SortOrder sortOrder, SearchOption searchOption)
    DirectoryInfo folderDirectoryInfo = newDirectoryInfo(folder);
    List<FileInfo> files = newList<FileInfo>(folderDirectoryInfo.GetFiles(includeMask, searchOption));
    stringexcludeMaskRegEx = FileSystemHelper.WildcardToRegex(excludeMask);

    // exclude files
files = (fromfile infiles
             where!Regex.IsMatch(file.Name, excludeMaskRegEx)

    if(files.Count > 0)
                // Sort files oldest first
                    delegate(FileInfo firstFile, FileInfo secondFile)
                // Sort files newest first
                    delegate(FileInfo firstFile, FileInfo secondFile)




/// <summary>
/// Convert a wildcard mask to regular expression
/// </summary>
/// <param name="pattern">wildcard string</param>
/// <returns>Regular expression string</returns>
public static string WildcardToRegex(string pattern)
    return string.Format("^{0}$", Regex.Escape(pattern).Replace("\\*", ".*").Replace("\\?", "."));

public enum SortOrder

SSIS package configuration

We have chosen to use a windows environment variable to hold the path to the *.dtsConfig, which is used to configure the *.dtsx package.

– Close all open Microsoft Visual Studio 2005 instances (because changing windows environment variables will have nog effect)

– Add a Windows Environment Variable:

– start > Control Panel > System > Advanced system settings > Environment Variables > New…

– Variable name: SSISPackage_Configuration

– Variable value: C:\Temp\SSISPackage.dtsConfig

– Click on [OK]

– Click on [OK]


– Open the Microsoft Visual Studio 2005 solution containing the SSIS project.

– Open the *.dtsx

– Click in the top menu on SSIS > Package Configurations …

– Check the Enable package configurations


– Click on Add …




When you start debugging the SSIS package in Microsoft Visual Studio 2005, the configuration will be red from the C:\Temp\SSISPackage.dtsConfig.

In production you can change the path of the environment variable and the configuration will then be red from that location.

Remove ExpandedColunCount and ExpandedRowCount when using Microsoft Exel (*.xml) file as template

When you use a Microsoft Excel "*.xml" file as template for generating Microsoft Excel reports, remove the ss:ExpandedColumnCount="1" ss:ExpandedRowCount="1" x:FullColumns="1" x:FullRows="1"

from the <Table> tag under the <Worksheet> tag. If you don’t remove these counters a error will occur, because the row and or column count is higher then 1:

Problem During Load
Problems came up in the following areas during load:
Worksheet Setting
This file cannot be opened because of errors. Erros are listed in C:\Users……\Content.MSO\7BF935F6.log


<Worksheet ss:Name="Sheet3">
  <Table ss:ExpandedColumnCount="1" ss:ExpandedRowCount="1" x:FullColumns="1" x:FullRows="1">
  <WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel">


An other error that can occur is:

XML ERROR in Table
REASON:    Bad Value
FILE:    C:\Temp\MyTest.xml
GROUP:    Table
TAG:    Row
ATTRIB:    Index
VALUE:    128


This was caused by the line:

<ss:Row ss:Index="128" ss:AutoFitHeight="0" ss:Height="12.9375">

Cause and solution

The index was not correct, by removing the ss:Index="128" ss:AutoFitHeight="0" ss:Height="12.9375" from the Row tag, the file could be opened correctly again.

Set text on control with javascript

To set the text on a control with javascript use:


    Set the text value of the given element.
    This function assumes this document is defined and not null and has a function getElementById
    Used by: -
function SetText(elementId, text)
    // Check input values
    if(IsNullOrUndefined(document)){alert('SetText: Object [document] is null or undefined');}
    if(IsNullOrUndefined(elementId)){alert('SetText: Object [elementId] is null or undefined');}
    if(IsNullOrUndefined(text)){text = '';}

    // Get the given element by id
    var resultGetElementById = document.getElementById(elementId);
    if(IsNullOrUndefined(resultGetElementById)){alert('SetText: Object [resultGetElementById] is null or undefined');}

    // Check if the firstChild is null or undefined
        // Element does not have a first node, add an textnode.
        // Element has a first childe node, so replace it's text value.
        resultGetElementById.firstChild.nodeValue = text;

Change cursor to hand with CSS, when mouse over a column in a ASP .NET 2.0 GridView

When you want to change the cursor to a hand instead of the default pointer on mouse over, use CSS.
In you're gridview column:
      <asp:TemplateField HeaderText="Barcode">
           <ItemTemplate><span class="hand"><%# Eval("Column")%></span></ItemTemplate>

In the header:

<style type=”text/css”>
.hand { cursor: pointer; cursor: hand; } /* cross browser hand */