Category Archives: VB.NET

Logging: how to get Class and Method names

When logging errors is helps to have the Class and method names where the exception was thrown without using string constants that are a pain to maintain. The code to get the names is Current assembly and class name = Me.GetType.FullName Current class name = Me.GetType.Name Current method (function or sub) = System.Reflection.MethodBase.GetCurrentMethod().Name
Posted in VB.NET | Leave a comment

How to run Xcopy with elevated privileges

A COM class to run xcopy as an admin.
Posted in VB.NET | Tagged | Leave a comment

How to run code as another user

A COM class that enables code execution under a different user identity. It makes it really easy to run code with elevated priviledges in eg VBA as well as NET.
Posted in VB.NET | Tagged | Leave a comment

Open a file in VB.NET

To open a file in it’s default application all you need is one line of code: System.Diagnostics.Process.Start("www.mysite.com") or System.Diagnostics.Process.Start("N:\myfile.pdf")
Posted in VB.NET | Tagged | Leave a comment