Open folders to process files automatically

J

jonathandrott

sorry newbie question probably. i'm trying to open an specific folder.
open each file with in the folder individually and process each one.
all the processing code has been written. i'm looking for sample code
to open the folder and start grabbing files. thanks.
 
M

Miro

Written in notepad...but it should be pretty close to what your looking for.
Goes and gets all the available folders in a folder...
then loops thru em and gets all the files per.
=====
Dim AllFolders() As String = Directory.GetDirectories("datadir")
Dim AvailableFiles() As String
Dim ArrayNum as Integer = 0

'go thru each subfolder and look for files
For ArrayNum = 0 To UBound(AllFolders)
AvailableFiles = _
Directory.GetFiles( AllFolders(ArrayNum), "*.txt")

'check here and loop again to add those files to some other
arraylist or something
Next

=====

Miro
 
J

jonathandrott

still not quite understanding this. i want to open a known folder
(i.e. "C:\ToProcess"). inside ToProcess is about 8-10 files, each
having a different name. so, i want to check if the files are there.
then, process the files with some code i have already written. right
now i'm set up to browse to the file and click a seperate process
button.

Program: open program, press process button, and files process one by
one.
 
I

Izzy

You'll need to be more specific about "I want to process the file".
Move it, Copy it, Read it, Modify it, Delete it.

The code above will get you a list of files, you just need to modify
the search string.

Once you have a list of files, check out System.IO.FileInfo OR
System.IO.File

I would post code too help you out, but specifics are needed.

Izzy
 
J

jonathandrott

never had to do this before... i don't understand how the array stores
the names of the files or how to call them back in my code so that i
can loop through.

"I want to process" =
i have a section of code that already is written to process the file.
(it opens it, reads it, moves it, then deletes it.) i want to do it
with a click of a button, instead of using file browser to select a
file, using a btn command to process the file, and selecting file
browse to select another file.

i'll be happy to email code.
 
I

Izzy

Sure send me the code. I'll write it and send it back with comments so
you'll understand what's happening.

Send the project to (e-mail address removed) along with a sample file.

Izzy
 
M

Miro

John, try this... ( in the mean time while izzy is looking at ur code )

Plop that code I gave you into ur program,
then put a Debug.Writeline( "put stop here" )
in the comment part i put.

Put a code stopper red dot in left hand side on it.

When the code stops here... go to the debuger and look what is in the array,
in the locals/ watch .

It took me a while when i first started ( about 1.5 months ago ) how to view
data in the debugger... it opend up a whole new world for me at the time. I
was in the same boat you were. - and probably still am for most things ;)

Miro
 

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