1

I stumbled upon this post while researching on the Delete Directory options available under:

  1. Microsoft.VisualBasic.FileIO.FileSystem.DeleteDirectory
  2. Directory.Delete

Is this statement true?

"Anyone says referencing the Microsoft.VisualBasic is often undesirable from within C#. Any association with VB from within C# code strikes me as undesirable"

Community
  • 1
  • 1
Arun
  • 2,493
  • 15
  • 12
  • Which one is your question? The difference between `Microsoft.VisualBasic.FileIO.FileSystem.DeleteDirectory` and `System.IO.Directory.Delete` or the subjective bit about referencing Microsoft.VisualBasic from C#? I hope the former. – R. Martinho Fernandes Apr 13 '11 at 16:37
  • No the latter - subjective bit.I was wondering what would be the issue, since referencing a .Net module (Microsoft.VisualBasic.FileIO.FileSystem) does not necesserily mean that I am using a Visual Basic code, though the namespace name has the term "VisualBasic" in it. – Arun Apr 13 '11 at 16:59

2 Answers2

1

Correct. The VisualBasic library is included primarily for backwards compatibility. It is greatly preferred (and probably more efficient) to use synonymous methods that are in the standard .NEt library.

Edit: But of course, for the linked post... when there is no equivalence, it's 'OK' to use the VisualBasic library

Zhais
  • 1,493
  • 12
  • 18
  • Thank you Zhais. From what I could dig in, Microsoft.VisualBasic.FileIO.FileSystem.DeleteDirectory was introduced from Framework 2.0 and it is still being supported in 4.0. – Arun Apr 13 '11 at 17:00
1

There is nothing wrong with referencing Microsoft.VisualBasic from any .NET language. I mean, other than uneasy feelings about its name.

It contains several methods to help porting VB6 code, but it also includes a couple of interesting shortcuts, like say, the AssemblyInfo class. If you're using Windows Forms, you can gain something if you inherit from WindowsFormsApplicationBase (like easy single-instance applications, or splash screens).

R. Martinho Fernandes
  • 228,013
  • 71
  • 433
  • 510
  • Thank you Martinho... I have been using this class for a while, and then saw the post quoted before. – Arun Apr 14 '11 at 20:52