refresh directory

D

Dave Cullen

My appplication spawns an external DOS process that creates a file. I
use Process.Start() and Process.Close() for calling that. After the
process closes, I look for the existance of the file it created.

The problem is that checking the existance of the file with
IO.File.Exists() fails, even though the file was created. If I step
through the program in debug mode it works fine.

Is there a way to "refresh" the directry first, so I'll see the file?
 
L

Lucas Tam

Dave Cullen said:
The problem is that checking the existance of the file with
IO.File.Exists() fails, even though the file was created. If I step
through the program in debug mode it works fine.

Is there a way to "refresh" the directry first, so I'll see the file?


Perhaps you are refreshing the directory too quickly?

Another alternative is to use the Directory.GetFiles method... you can
specify a file filter to return only the file names you want.
 
C

Cor Ligthert

Dave,

Are you sure the seperated proces is ended when you do the IO.File.Exist?

Cor
 
H

Herfried K. Wagner [MVP]

Dave Cullen said:
My appplication spawns an external DOS process that creates a file. I
use Process.Start() and Process.Close() for calling that. After the
process closes, I look for the existance of the file it created.

Use 'Process.WaitForExit' to wait for the process to exit. Then check if
the file exists.
 
C

Cor Ligthert

Herfried,

Give you always the answer that is probably obvious from my message, that
makes it impossible to do a simple dialog in this newsgroup?

Cor
 

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