Next File (System.IO)

  • Thread starter Thread starter ElmoWatson
  • Start date Start date
E

ElmoWatson

Let's say I have a file loaded, whether it be text or picture.

I want to be able to have a 'Next' button, which loads the next file in the
current directory.

I can load the files just fine, and to some extent, I understand System.IO
(deleting/path designations, etc), but how can I look at the path of that
first file, which is loaded, and load the next one in the path?
 
The System.IO.Directory.GetFiles() method will return an array of the file
paths of all the files in the directory. You can work off of that.

--
HTH,

Kevin Spencer
Microsoft MVP
Software Composer
http://unclechutney.blogspot.com

I had the same problem once. Fixed it using the same solution.
 
Can you point me to a website that shows how to do this?
I'm kind of lost on how to do it still.....
 
The System.IO.Directory.GetFiles() method will return an array of
Can you point me to a website that shows how to do this? I'm kind of
lost on how to do it still.....


first get all files, maybe in some init-code:
string[] files = System.IO.Directory.GetFiles();
int currentFile = 0;

then use this list to loop over this:

void OnButtonNextClick(...)
{
currentFile++;
string newFile = files[currentFile];
// do whatever you need with the new file
}

hope this helps
Markus
 
Did you try googling it yourself? Or go search msdn2.com for
system.io.directory.getfiles() ?

Robin S.
--------------------------------------
 
Back
Top