Programer help

KING_OF_SAND

New member
As the title says I need help developing a program. It is a Map Manager for a specific game (TOP SECRET for now). I am developing this program in C# and I can not for the life of me figure out how to get the 'CheckedListBox' to display what I have in a folder. The folder will contain .zip or .exe files, I have not decided yet. But I want the box to display those files.

How do I do this?
 
Code:
System.IO.DirectoryInfo DAN = new System.IO.DirectoryInfo("PATH HERE (example c:\)");

System.IO.FileSystemInfo[] files = DAN.GetFileSystemInfos();

CheckedListBox1.Items.AddRange(files);

Replace the DAN with something more relevant.

Hope this helps.

Rough code as I do not have C# installed...

Work on this code if need be.

Code:
using System.IO;

Directory.GetFiles(@"c:\DIRHERE\");

you can always expand it by using , "*.bmp"); at the end so you can filter out filetypes

So.

Code:
string[] filePaths = Directory.GetFiles(@"c:\DIRHERE\", "*.bmp");

Remember to include

using System;

using System.IO;
 
Clearer code:

Code:
 private void button1_Click(object sender, EventArgs e)

{

//contents of directory stored in "strPath"

DirectoryInfo dirinfoz = new DirectoryInfo(strPath);

//create array that holds requested files from folder stored in "dirinfoz" variable

FileInfo[] rgFiles = dirinfoz.GetFiles("*.*");

//move through FileInfo array and store in new array of fileinfoz

foreach (FileInfo fileinfoz in rgFiles)

{

checkedListBox1.Items.Add(fileinfoz.Name); //list files in CLB

}

}
 
Clearer code:

Code:
 private void button1_Click(object sender, EventArgs e)

{

//contents of directory stored in "strPath"

DirectoryInfo dirinfoz = new DirectoryInfo(strPath);

//create array that holds requested files from folder stored in "dirinfoz" variable

FileInfo[] rgFiles = dirinfoz.GetFiles("*.*");

//move through FileInfo array and store in new array of fileinfoz

foreach (FileInfo fileinfoz in rgFiles)

{

checkedListBox1.Items.Add(fileinfoz.Name); //list files in CLB

}

}

I noticed you had the code under "button_1" shouldn't this be under chcheckedListBox1?
 
I noticed you had the code under "button_1" shouldn't this be under chcheckedListBox1?

button1 was an example mate, you just need the code below that. You could use it for example on form load, on button press or using a timer, it's up to you.
 
Good, no worries, it's what we're here for lol
smile.gif
.
 
This may come across as a stupid question as their has got to be an easy way to do this. How can a move a .cs file to another folder?
 
This may come across as a stupid question as their has got to be an easy way to do this. How can a move a .cs file to another folder?

in a project???

just drag and drop it

if it from another external project.... just "add existing file" and change the namespace
 
Move the file into the required folder, then add the file then alter the NS.

edit... nvm I didn't see last 2 posts
tongue.gif
 
Back
Top