In your code it is not ensured that the stream is closed properly. If an error is occurred before calling Close or Dispose, the resource remains blocked. Use try-catch-finally and release resources in the finally block, log failures in the catch block - do not use Close and Dispose too, Dispose is enough.

The process cannot access the file - after disposing InputStream
I need for my app to shutdown the device if there is 10 minutes or more of inactivity.  So what is best way to detect and shutdown after 10 minutes?  Thanks
