Search code examples
c#directoryremote-accessdelete-filedelete-directory

How to get remote folder names, select them and delete them in C#?


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 :(


Solution

  • 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.