Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. How to Override FileSystemInfo Class Readonly properties (Exists, Extension, Name, and etc)?

How to Override FileSystemInfo Class Readonly properties (Exists, Extension, Name, and etc)?

Scheduled Pinned Locked Moved C#
helpc++sysadmintutorialquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    ShadowUz
    wrote on last edited by
    #1

    I am using a C++ DLL, where one of the parameters is a FileSystemInfo Class. The problem is, I am retrieving all file properties from a server. And have to assign all the properties to the class and return it to C++ DLL. I have tried to create my own FileSystemInfo class with {get; set} properties, but getting this error:

    Cannot convert MyClass.MyFileSystemInfo to System.IO.FileSystemInfo

    E 1 Reply Last reply
    0
    • S ShadowUz

      I am using a C++ DLL, where one of the parameters is a FileSystemInfo Class. The problem is, I am retrieving all file properties from a server. And have to assign all the properties to the class and return it to C++ DLL. I have tried to create my own FileSystemInfo class with {get; set} properties, but getting this error:

      Cannot convert MyClass.MyFileSystemInfo to System.IO.FileSystemInfo

      E Offline
      E Offline
      egenis
      wrote on last edited by
      #2

      Is this what you are looking for?

      using System.IO;
      ...

      public class MyFileSystemInfo : FileSystemInfo
      {
      public string SomeProperty { get; set; }
      public string SomeOtherProperty { get; set; }

      public override void Delete()
      {
          throw new NotImplementedException();
      }
      
      public override bool Exists
      {
          get { throw new NotImplementedException(); }
      }
      
      public override string Name
      {
          get { throw new NotImplementedException(); }
      }
      

      }

      Implement the abstract class FileSystemInfo and add the properties you require. You can then wrap the readonly properties of the base class to suit your needs?

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups