• Post Reply Bookmark Topic Watch Topic
  • New Topic

Other application opening a file  RSS feed

 
Gaurav Sinha
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,
Is there a way , with the help of which we can determine , whether any other application have opened the file or not.

For Ex:
If I give path to a txt file , and if have used notepad , to open that file , the function should return false , and as I close that file , the function in that case , should return true.


I got one method ,
if we try to rename the file....or try to set to set last modified time.....and if its really opened by some application ..........it won't allow me to rename it or change the time
but the problem occurred with *.txt file.
If I open a txt file with a notepad , after opening the file , I can even delete the file or rename the file.
So what to do in such case.

-Gaurav
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch.

There's probably no general solution. Some applications may keep the file open while they show it in the GUI; others (such as Notepad, apparently) just read it, but don't keep it open.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!