tags:

views:

69

answers:

2

Hi everyone,

I'm writing an ASP.NET webapp that will copy the contents of a CD to a network share. I need to check periodically if the copy job is finished.

One way of doing this is checking the network share folder to see if the file size has changed since the last check, but that seems kind of dodgy. Does anyone have a better idea how to do this?

Thanks in advance, Stijn

EDIT
some more explanation:
Basically I'm calling a JsonResult action method every 5 seconds, called getStatus(source,destination). This method needs to check the following:
- if the source dir is still empty, copy cannot start --> return status "waiting"
- if the source dir contains files, copy can start -_> call copy method + return status "copying"
- if the destination dir contains files, and file size stays the same, copy is finished --> return status "finished"

Thanks!

+2  A: 

In your webapp, use a blocking file copy operation, such as File.Copy, but run the procedure that does the copying in a background thread. In your background thread, write status information (e.g. "3 of 9 files finished" or "I'm done!" or "Error occurred: ...") into some shared object (static variable, Session object, database, ...). Then write some Status.aspx page which shows the content of that shared object.

Heinzi
A: 

Create web services available from client's javascript side with 2 methods: StartCopying, CheckStatus.

  • Implementation of StartCopying can either start backgorund thread to copy, or have [SoapDocumentMethod(OneWay = true)] that is mean that method returns immediately without waiting accomplishment.
  • CheckStatus just checks what you have described above, and return to client status of task.
Dewfy