Home > Software design >  How to check whether a txt file is open?
How to check whether a txt file is open?

Time:12-09

Is there any way to find out which file is open or not?

I want to know if the file is opened in word office or not. and then return true if it is open. which module should I use to get that info.

I tried many things and did not find a way to do it. if you can help me, I would really appreciate it.

CodePudding user response:

Yes, it is possible to determine whether a file is open in Word or any other program. One way to do this is by using the Task Manager in Windows. You can open the Task Manager by pressing Ctrl Shift Esc on your keyboard, and then look for the name of the file in the list of running processes. If the file is open in Word or another program, it will appear in the list and you can determine which program it is open in.

Another way to check if a file is open in Word is by using the fuser command in Linux. This command allows you to see which processes are accessing a specific file, including any instances of Word that may have the file open. For example, you could use the following command to check if a file named "my_file.docx" is open in Word:

fuser my_file.docx

CodePudding user response:

Just use if-else statement if file will be in correct format then

  • Related