My.Computer.FileSystem和System.IO.File命名空间中存在大量重复的功能.
那究竟是什么区别:
- My.Computer.FileSystem.CopyFile(source,dest,True)
和:
- System.IO.File.Copy(source,True)
是否存在性能差异?什么是每个人对哪些具有阅读能力优势的看法?我个人使用My.Computer命名空间,但这只是习惯.
我的.*只是为VB.NET实现的一组Facade模式类,包含常见的System.IO *(和其他)操作.由于你经历了一个额外的抽象层,所以有一个非常微小的性能损失,但你必须决定它是否值得优化.我建议使用对你和你店里的其他人有意义的方式.
如果使用.NET Reflector检查My.Computer.FileSystem.CopyFile的代码,您将看到该方法包装了许多System.IO类,例如File和Directory,尤其是File类的Copy,Move和Delete方法.片段:
- 'lots of other code snipped out for brevity and to show the use of System.IO classes...
- Directory.CreateDirectory(FileSystem.GetParentPath(str))
- 'snip
- If
- ' snip
- Else
- File.Delete(str)
- File.Move(path,str)
- End If
- Else
- File.Move(path,str)
- End If
- End Sub