Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read

Sponsored Links



Program to see file used by another process

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 08-03-2010
Member
 
Join Date: Dec 2009
Posts: 296
Program to see file used by another process
  

Hello,
I would like to test if a file is used by another process.
I try to do the following code, have a look at it
Code:
canRead() and canWrite()
but it returns true even if the file is opened. Do you have a similar program that is the source code of it. If you have such a code or have any idea of how to do it then please let me know I am the interested one here. Thanks in advance.

Reply With Quote
  #2  
Old 08-03-2010
Member
 
Join Date: Nov 2009
Posts: 343
Re: Program to see file used by another process

Hello,
With the File class, you can not. What you can do is create a FileInputStream or FileOutputStream, and do a close (). I recommend you to use a try / catch around, and if an exception is thrown, it's that close () failed, so your file is used for reading or writing. I think you should first have any idea of the java.io package that contains all the input and the output classes which are used in the I/O programs in java. So, I strongly recommend you to first learn or take a look at the java.io package.
Reply With Quote
  #3  
Old 08-03-2010
Member
 
Join Date: Nov 2009
Posts: 356
Re: Program to see file used by another process

Hello,
Attention because it can be dangerous. Even if you write anything in it, simply open a FileOutputStream erase the contents of the file. In addition, a file can be used by multiple programs simultaneously. So you will not get necessarily exceptional. While using the java.io package that is the classes in the package first understand what you are trying to do with the program of the file which you are dealing with, if you miss something in the program then it can be dangerous for the file, that is you can even loose the file.
Reply With Quote
  #4  
Old 08-03-2010
Member
 
Join Date: Dec 2009
Posts: 204
Re: Program to see file used by another process

Hello,
Even I am searching for a similar program, I have a treatment that launches executable via Process.exec () and this treatment aims to repatriate me a csv file from the machine that starts the process and creates the csv file into a new file whose name is the date of launch given parameter. But the whole thing is not quite working for me. If you have any solution for this then please help me with this. Thanks in advance.
Reply With Quote
  #5  
Old 08-03-2010
Member
 
Join Date: Dec 2009
Posts: 296
Re: Program to see file used by another process

Hello,
This is my updated code please have a look at it and if you find any problems in the code then correct me with the same
Here is my code:

Code:
do {
				try {
					Thread.sleep(10000);
				} catch (InterruptedException e) {				
					e.getMessage();
				}
				try {
					 f = new File(fluse);
flinstr = new flinstr(fluse);
				} catch (FileNotFoundException e1) {			
					e1.getMessage();
comments.add("File"+ + fluse"Was not loaded => f not found problem");
				}
			} while (! f.canRead());
Reply With Quote
  #6  
Old 08-03-2010
Member
 
Join Date: Nov 2009
Posts: 359
Re: Program to see file used by another process

Hello,
Do not know exactly that this is what you want, but have a look at the following code, may help you
Code:
try {
			Process = runtime.getRuntime().exec(shellCommand);
p.waitfor();
		} catch (IOException ioe) {		
			ext.getIOException(ioe);
comt.add("The file was not executed APPTMP.csv => execution problem");
		}catch (InterruptedException e) {
			comt.add("there is a problem of p execution");
		}
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Program to see file used by another process"
Thread Thread Starter Forum Replies Last Post
Configuration process starts every time I open an Office program Manik MS Office Support 1 04-02-2013 10:21 AM
Learning Batch file to open a program or a file Ikshana Windows Software 3 04-04-2011 07:24 PM
How do I tell what process owns a file? JamesB Operating Systems 3 27-07-2009 08:45 PM
How to conclude Which Windows Process is Using a File Jaisudha Operating Systems 3 06-07-2009 11:59 AM
How to terminate Process and Delete the Source Program with Ultimate Process Killer jackalz Tips & Tweaks 1 26-03-2009 06:31 PM


All times are GMT +5.5. The time now is 05:29 AM.