Search code examples
vb.netinheritancesystem.io.directory

Why Can't I Inherit IO.Directory?


Why can't I create a class in VB.NET that inherits System.IO.Directory? According to Lutz Roeder, it is not declared as NotInheritable!

I want to create a utility class that adds functionality to the Directory class. For instance, I want to add a Directory.Move function.

Please advise and I will send you a six pack. OK nevermind I'm not sending you anything but if you come to the bar tonight I will hook you up and then beat you in pool.


Solution

  • From the Meta Data of .NET

    namespace System.IO
    {
        // Summary:
        //     Exposes static methods for creating, moving, and enumerating through directories
        //     and subdirectories. This class cannot be inherited.
        [ComVisible(true)]
        public static class Directory
    

    You cannot inherit from a Static Class.