VB Migration Partner


Previous | Index | Next 

[PRB] Most VB.NET methods don’t work well with strings that contain ASCII 0 characters

Most methods in the VB6 runtime – for example, GetAttr and SetAttr - automatically truncate a string to the first ASCII 0 char; this behavior is very convenient when working with strings returned from Windows API calls, for example. Unfortunately, the corresponding VB.NET methods don’t truncate the string and therefore throw the following exception

        Illegal characters in path

VB Migration Partner’s support library comes with a set of replacement file-related methods that fix this behavior and automatically truncate their string arguments at the first ASCII 0 char. The provided methods are: ChDir6, ChDrive6, FileCopy6, FileLen6, MkDir6, RmDir6, GetAttr6, SetAttr6, Kill6.

However, please notice that VB Migration Partner doesn’t automatically map the native VB.NET methods to the replacement methods listed above, because relatively few programs may suffer from this minor behavior difference. If you want to enforce the string truncation you should manually change the VB.NET method into the VB Migration Partner’s method.

Such change can be performed easily and automatically by means of the following pragma:

 '## PostProcess "\b(?<fn>ChDir|ChDrive|FileCopy|FileLen|MkDir|RmDir|GetAttr|SetAttr|Kill)(?=\()", 

As with all PostProcess pragmas, you can change its scope so that it works for the entire project or for a single file. Additionally, you can change the regular expression in its first argument to limit its effect to a subset of all file-related methods.

Previous | Index | Next 

Follow Francesco Balena on VB6 migration’s group on


Read Microsoft Corp’s official case study of a VB6 conversion using VB Migration Partner.

Code Architects and its partners offers remote and onsite migration services.

More details

Subscribe to our free newsletter for useful VB6 migration tips and techniques.


To learn more about your VB6 applications, run VB6 Analyzer on your source code and send us the generated text file. You will receive a detailed report about your VB6 applications and how VB Migration Partner can help you to quickly and effectively migrate it to .NET.

Get free advice

A fully-working, time-limited Trial Edition of VB Migration Partner allows you to test it against your actual code

Get the Trial

The price of VB Migration Partner depends on the size of the VB6 application, the type of license, and other factors

Request a quote

Migrating a VB6 application in 10 easy steps

Comparing VB Migration Partner with Upgrade Wizard

Migration tools: Feature Comparison Table

All whitepapers