How to Override FileSystemInfo Class Readonly properties (Exists, Extension, Name, and etc)?
-
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
-
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
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?