Posso renomear um arquivo aberto no Windows XP?

2

Eu quero renomear programaticamente um arquivo e ele pode estar aberto. É um arquivo de log. Quando estava testando meu código, a parte de renomeação não funcionava porque o arquivo de log TestPro.log era aberto pelo TAF (Test Automation Framework).

Quando o TestPro está em execução e tento excluir o arquivo, recebo o erro "Não é possível excluir porque está sendo usado por outra pessoa ou programa".

Existe alguma maneira de renomear um arquivo (programaticamente) que é aberto da mesma forma que o arquivo de log?

    
por Radek 28.05.2012 / 08:29

3 respostas

1

A solução é usar a versão de linha de comando do Unlocker antes de mover / remover o arquivo.

    
por 28.05.2012 / 09:10
1

O melhor é MoveFile de Sysinternals .

    
por 23.09.2012 / 10:57
0

Espero que você encontre respostas aqui :

There are several reasons why Windows might not allow you to delete a file:

  • The file might be in use in which case you can't delete the file until the program using it gives it up.
  • The file might be marked read-only.
  • The file name might be so long that Windows can't handle it. File names with more than 260 characters in them are often difficult to delete.
  • There are also several reasons why Windows might not allow you to change the name of a file; particularly its extension. All above apply here; as well as...

  • Your system may not be showing file extensions by default.

We'll cover that one first and the others in turn.

[…]

Sometimes you can't seem to delete a file or folder no matter what you do. In this case there are a few programs that might help you.

  • MoveOnBoot
  • Delete FXP Files
  • Delinv
  • Unlocker

If, after all this you still can't rename/delete a file, not certain what else to suggest. Others have this problem often and as different ideas might come up in the FILExt forum I'll change this FAQ to include them. If you find a method that works for you and is not in this FAQ, please drop FILExt a note with details on that method so it can be added to the FAQ.

    
por 28.05.2012 / 10:33