0

I am trying to get the name of a network drive (the relative path will not work with File.Copy). I found this stackoverflow page that suggests using DriveType. I'm having an issue with my project not recognizing the class. The Microsoft page says it is part of the current framework, I've got a using statement for System.Management, and I've got my target framework set at 4.6.1.

  1. Is there something I'm missing that is preventing me from using this class?
  2. Is there a better way to get the network drive path so File.Copy will work?
B Minster
  • 331
  • 3
  • 16
  • It is not a class in the .NET sense, you only ever use it in a string. The compiler will never complain about a string. We can't see what you are doing, that makes it too hard to help you. Consider to use the WMI Code Creator utility to experiment, it can auto-generate the C# code you need. – Hans Passant Sep 18 '17 at 16:20
  • Well, I can't use the ManagementPath() or ManagementObject() methods for some reason. `var managementObject = new ManagementObject()` says the type or namespace name cannot be found. – B Minster Sep 18 '17 at 19:23
  • 1
    Use Project > Add Reference > select System.Management – Hans Passant Sep 18 '17 at 19:28

1 Answers1

0

As Hans Passant says above, in Visual Studio right click your project in Solution Explorer and choose Add Reference. From the .NET tab choose System.Management.