FileListBox

P

Pete Davis

Well, first of all, FileListBox is a VB6 construct, which has nothing to do
with C#.

The .NET equivalent that you should use are the OpenFileDialog or
SaveFileDialog classes.

These also have no way to get the number of files in a directory, largely
because it's generally irrelevant to the job of providing the user with an
interface to choose a file from.

On the other hand, using the Directory.GetFiles() method, you can get an
array of files in a directory and you can then get the length of the array
to know the count.

Pete
 
I

Ismail Rajput

Consider Visual Studio Dot Net

Why fileListBox does not have filecount method available?If it is really not
available then what can be the other way to count number of files in a
filelistbox?
 
J

Jochen Kalmbach

Ismail said:
Why fileListBox does not have filecount method available?If it is
really not available then what can be the other way to count number of
files in a filelistbox?

What is a filelistbox !?
..NET framework does not have a class called "filelistbox"

Do you mean "OpenFileDialog" and "SaveFileDialog" !?

Or do you mean the VB6.FileListBox !? which should be only used for
upgrading VB6 to .NET !?

See: FileListBox Control Changes in Visual Basic .NET
http://msdn.microsoft.com/library/en-
us/vbcon/html/vxconchangestofilelistboxcontrolinvisualbasicnet.asp


But if you mean "OpenFileDialog" then I do not understand you
question...
Is "FileNames.Length" not enough !?

<code>
using(System.Windows.Forms.OpenFileDialog ofd = new
System.Windows.Forms.OpenFileDialog())
{
ofd.Multiselect = true;
if (ofd.ShowDialog() == MB_OK)
{
MessageBox.Show(ofd.FileNames.Length.ToString() + " files
selected");
}
}
</code>

--
Greetings
Jochen

Do you need a memory-leak finder ?
http://www.codeproject.com/tools/leakfinder.asp

Do you need daily reports from your server?
http://sourceforge.net/projects/srvreport/
 
J

Jochen Kalmbach

I

Ismail Rajput

Anyway , i think i can't count it like that.

I will now go to System.IO and use GetFiles and populate in .NET ListBox?

what do you say ?
 
I

Ismail Rajput

I think you didn't get me ,

if you go to tools and add.remove toolbox items , there you can add
filelistbox to your toolbox and that can be used with C sharp.
 
J

Jochen Kalmbach

Ismail said:
I think you didn't get me ,
Maybe.

if you go to tools and add.remove toolbox items , there you can add
filelistbox to your toolbox and that can be used with C sharp.

And what is the problem with this?

My question is:
Do you want to count file insie a directory or do you want to count entries
inside some dialog?


--
Greetings
Jochen

Do you need a memory-leak finder ?
http://www.codeproject.com/tools/leakfinder.asp
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top