-2

In C#, I want to populate a checkListBox with files from a certian file directory using a button so the user can then check the files in the checkListBox. Then in another button click, move the checked files that populate the checkListBox to their desktop on their computer.

Please help me this is very important. I have no code because I have nothing to start with.

  • 1
    If it's very important, then you should take time to learn those things. You have not provided us with any code to show any effort. Please refer to http://stackoverflow.com/help/on-topic regarding what sort of questions should be asked here. – B.K. Oct 22 '15 at 17:28

1 Answers1

0

Well I suggest that you will create a new Winforms application. Then drag Checklistbox and button into form and arrange them.

Then double click form at any area except over buttons and checklistbox. Now you should have a function which is called when application is loaded (this way you dont need another button to load files into checklistbox).

Now use Directory.GetFiles method to get all files form certain directory. Checklist items are added with method CheckedListBox.ObjectCollection.Add(...)

Now go back to designer mode where you see a form, checklistbox and button. Double click button to create a event handling for button click.

Then use foreach loop to iterate through all checked items from checklistbox objectcollection and call File.Move for each item which is checked.

Use full absolute file paths, they are easy to use in this scenario.

File Move: https://msdn.microsoft.com/en-us/library/system.io.file.move(v=vs.110).aspx

Get Files: https://msdn.microsoft.com/en-us/library/07wt70x2(v=vs.110).aspx

Similiar question and some answers: Find all files in a folder

Community
  • 1
  • 1
Panu Oksala
  • 3,245
  • 1
  • 18
  • 28