This documentation is archived and is not being maintained.

TextFieldParser.SetFieldWidths Method

Sets the delimiters for the reader to the specified values.

Namespace:  Microsoft.VisualBasic.FileIO
Assembly:  Microsoft.VisualBasic (in Microsoft.VisualBasic.dll)

public void SetFieldWidths(
	params int[] fieldWidths
)

Parameters

fieldWidths
Type: System.Int32[]
Array of Integer.

The existing contents of the Delimiters property are cleared when this is set.

This method provides a way to set delimiters without creating an array.

The following table lists example of tasks involving the SetFieldWidths method.

This example opens a text-field parser and defines the field width as 5.


Using FileReader As New Microsoft.VisualBasic.FileIO.
    TextFieldParser("C:\logs\test.log")

    FileReader.SetFieldWidths(5)
End Using


Replace the path C:\logs\test.log with the path and name of the file you wish to parse.

The following example opens a text-field parser and defines the field widths as 5, 10, and variable.


Using MyReader As New Microsoft.VisualBasic.FileIO.
    TextFieldParser("C:\logs\test.log")

    MyReader.SetFieldWidths(5, 10, -1)
End Using


Replace the path C:\logs\test.log with the path and name of the file you wish to parse.

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Show: