Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Test if folder can be renamed

Status
Not open for further replies.

bbuk

Technical User
Apr 27, 2002
44
0
0
GB
Hi

I have a simple app which renames 3 files and 2 folders to switch between multiple installations of another app. To keep things simple I use the Name statement.

All is well unless the user decides to open one of the sub folders in explorer which results in my app crashing because the top level folder cannot be renamed.

I have got round this by using an error trap function which renames the file or folder then if successful, i.e. no error occurs, renames it back to the original. If all files and folders test ok then the switch occurs, otherwise an error message is displayed advising the user to close open windows and retry.

While this works it is very clumsy and I wondered if anyone can suggest a more elegant solution. Windows knows whether the folder can be renamed so can this information be tested via an api call for example?

t..i.a.

Andy
 
Are you sure that simply having a subfolder open in Explorer prevents VB from renaming the parent folder? I find that hard to believe and if it's true I'm amazed I've never run into the same problem.

Are you sure the cause of the situation isn't that an app like Word or Excel has a file open within the folder you're trying to rename? I don't know whether that would actually cause a problem but I think it would be more likely to do so than Explorer.

- Andy
___________________________________________________________________
If you think nobody cares you're alive, try missing a couple of mortgage payments
 
Thanks for the reply Andy & sorry for the delay - I have been away.

Yes I have done some tests and just having the folder open is enough. If it is the top level folder, i.e. the one I am trying to rename it is OK but any sub-folder will cause the problem.

Andy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top