0

I am brand-new in C# and I wanna do that in C#. Can you show me the way :)

  • Enter a remote machine hostname
  • get list folder names in C directory from the remote machine
  • select folder names from the list
  • delete the selected folders
  • show a message about the process (deleted or not)

Is that too hard? Thank you for your help in advance and sory for my bad English :(

serdar
  • 147
  • 6
  • 1
    Unfortunately this is too broad for Stack Overflow. If you have problems with a specific issue, please show what you have tried and then others may be able to help you. – Sami Kuhmonen Mar 26 '16 at 14:25
  • Sure. S Tart learning the language. Then read the relevant namespaces (Hm, folder - that sounds like System.IO) from the manual. What classes are there, what methods do exist. Then you are smarter. T His is the way people that want to be good do it. – TomTom Mar 26 '16 at 14:37
  • Yes; you are right :( But I wanna learn :( – serdar Mar 26 '16 at 14:38

2 Answers2

2

Remote and local file system access in C# (.NET) works the same way. Try for example the following.

var directory = new System.IO.DirectoryInfo("\\server\path\remote\C");
var files = directory.GetFiles();
foreach(var f in files) f.Delete();

For remote drives, for example drive C, the path will be like: \server\c$\folderUnderC (note the dollar sign).

Lzh
  • 3,585
  • 1
  • 22
  • 36
0

A broad question, here are a few general answers.

Enter a remote machine hostname

Set up a GUI for that (WinForms or whatever you like)

get list folder names in C directory from the remote machine

Look into remote directory services, especially Samba / SMB setup and access for Windows. This question will be usefull.

select folder names from the list

With the appriopiate GUI elements (a TreeView maybe), easily possible.

delete the selected folders

Issue a File.Delete() command for the appropiate path, see link above.

show a message about the process (deleted or not)

Wrap above command in a try-catch, then call MessageBox.Show() or whatever GUI elements you want for that.

Community
  • 1
  • 1
Maximilian Gerhardt
  • 5,188
  • 3
  • 28
  • 61