Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is the equivalent of My.Computer in c# [duplicate]

Tags:

c#

vb.net

Possible Duplicate:
VB.NET to C# - my.computer.getfiles()

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)

Thanks in advance..

like image 304
Ramesh Avatar asked Aug 02 '12 13:08

Ramesh


1 Answers

From the documentation

Use the File class for typical operations such as copying, moving, renaming, creating, opening, deleting, and appending to files. You can also use the File class to get and set file attributes or DateTime information related to the creation, access, and writing of a file.

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);
like image 131
Nick Avatar answered Oct 05 '22 23:10

Nick