本文介绍了c# 中 My.Computer 的等价物是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能的重复:
VB.NET 到 C# - my.computer.getfiles()

谁能告诉我在 C# 中遵循 vb.net 代码My.Computer"方法的等效方法.

Can any one tell me the equivalent of following vb.net code 'My.Computer' methods in C#.?

My.Computer.FileSystem.RenameFile(oldname,newname)
My.Computer.FileSystem.DeleteFile(filename)

提前致谢..

推荐答案

来自 文档

将 File 类用于典型操作,例如复制、移动、重命名、创建、打开、删除和附加到文件.您还可以使用 File 类来获取和设置与文件的创建、访问和写入相关的文件属性或日期时间信息.

您可以使用 System.IO.File 来完成我对 VB 的有限了解说 My.Computer.FileSystem 可以做的大部分事情.

You can use System.IO.File to do most of the things that my limited knowledge of VB said My.Computer.FileSystem could do.

这些方法仍然是静态的,并采用您要操作的文件的路径.因此,对于您提供的示例...

The methods are still static, and take in the path of the file you wish to manipulate. So for the examples you provided...

File.Move(oldname, newname);  //File renames things just like Unix does- by moving them
File.Delete(filename);

这篇关于c# 中 My.Computer 的等价物是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-28 10:41
查看更多