File.Copy problems & other file problem

L

Lloyd Dupont

1st. funny fact about File.Copy:
=====================
File.Copy(src, dst, true)
with dst being an existing hidden file fail with a SecurityException
it's kind of weird because the application itself was the one which created
this hidden file in the 1st place.
so I have the strange bug of being able to edit this file, but not use
File.Copy() to overwrite it.....
weird.. :-/
Anyway I fixed it by simply removing the hidden attribute on dst before
overwritting it... :-/


2nd. How to check if a file is in use:
========================
I have an app which work with user file and a 'working shadow copy' (which
is, in fact, a database file updated live for every user's update to data).
Now I must close this database file when closing the application, but it
could be that an other (running instance of my) application is using the
same shadow file as well (shadow file name is a function of user filename).
In which case I can't delete it, it causes an exception: file in use.
Fair enough, but is there a way to test that other than by getting the
exception?
 
G

Guest

Trap the error and evaluate it.
Ex,
on error resume next
'code to delete
if err.number = 0 then ........

or use try...catch
 

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