3
Answers

Difference b/w My.Computer.FileSystem & System.IO.Directory

amShekar

amShekar

11y
2k
1
What are the differences between My.Computer.FileSystem and System.IO.Directory

Iam using My.computer.FileSystem in my existed application to do some IO operation such as getfiles, copy files, move files,delete files.
Instead of getfiles i want to use enumeratefiles method but enumerate is not present in my.computer.filesystem so i wanted to replace it with System.IO.directory .

 Is there a performance difference?
 Pros and cons ?
Answers (3)
1
Vulpes

Vulpes

NA 98.3k 1.5m 11y
The purpose of the My namespace is to make it easier for VB.NET programmers to navigate classes in the .NET framework which carry out common tasks.

As such it's basically a wrapper for existing .NET classes though (as you've seen with the EnunerateFiles method) it doesn't support everything that those classes can do.

On the other hand there may be some stuff which My can do which the basic .NET classes can't do by calling directly into the Win32 API which (together with COM) underlies the whole of .NET.

So My is basically just a 'convenience' feature and there shouldn't be any appreciable difference between using the My namespace and accessing the underlying classes directly.

Also there's no reason why you shouldn't 'mix and match' the two approaches in the same application - you don't need to exclusively use one or the other.

0
Vulpes

Vulpes

NA 98.3k 1.5m 11y
Yes, that's correct.
0
amShekar

amShekar

NA 39 39.7k 11y
Thanks vUples ,
i can mix both rite i.e wherevr i want enumerator there i can use System.IO.Directory instead of My . Both will server for same right !! ?