How to check if a file is being read by another program?

Hey all,
I just have a few question for a project I am doing:
How do I check if a file is being read by another program?
How do I check how many lines it read?
How do I get Keyboard input from the user when he is using another program other than mine? Ex: Pressing Ctrl-G to take a screenshot.
How can I halt another program from reading a file when it already opened it? Ex: The other program opened a file and began reading. Now it is at line 2 and I want to make it skip 10 lines and contontinue.
Thanks,
Bluelikeu

How do I check if a file is being read by another
program?This is about the only partially sensible question you asked. But the answer is that unless you use some native code, you can't.
How do I check how many lines it read?It doesn't even make sense to ask this question. First of all, what's a "line" anyway? Files are just sequences of bytes. A "line" is only in the interpretation of those bytes, such as if it contains <cr><lf> sequences an application may choose to render the contents of those bytes as logical "lines" of string sequences. Second of all, why the heck would it matter to you how many bytes have already been read by some other process(es)?
How do I get Keyboard input from the user when he is
using another program other than mine? Ex: Pressing
Ctrl-G to take a screenshot.You want to spy on other applications? Shame on you, Mr. Spyware creator.
How can I halt another program from reading a file
when it already opened it? Ex: The other program
opened a file and began reading. Now it is at line 2
and I want to make it skip 10 lines and contontinue.Shame on you Mr. Spyware creator.

Similar Messages

  • How to check whether INSO Filer is being used or not?

    Hi,
    We have created full text search indexes using the default syntax -
    CREATE INDEX FTI ON DOCUMENTS(DOC_FILE) INDEXTYPE IS CTXSYS.CONTEXT;
    How can I find out whether the INSO filter is used or not. Also a basic question, INSO filter helps in reading and "crawling" some 100+ document formats and creating an index against which search could be executed.... right?
    Please do let me know.
    Thanks & Regards,
    Dhwanil

    you can specify the inso filter in index code creation.
    create index TEST_IDX
    on TEST_TABLE (TEXT)
    indextype is ctxsys.context
    parameters('filter     ctxsys.inso_filter');

  • How to tell if a file is being used by another process?

    Thanks to nrlz for helping me with my last question http://forum.java.sun.com/thread.jsp?forum=31&thread=387999&tstart=15&trange=15 i have been able to make my virtual folder containing folders :) sort of a tounge twister :)
    However i have had to put in a 1 second delay before running the script after i create it otherwise the script will fail as it thinks the file is still being used by the java program.
    I wish to know how to test for wether a file is currently locked by a process (with out trying to create a File() instance in a try/catch block as this would lock the file again :/ )
    the program is below.
    If you are using win98 you may need to change:
    Runtime.getRuntime().exec("c:\\winnt\\system32\\wscript.exe \"createShorcut.vbs\"");
    to
    Runtime.getRuntime().exec("c:\\windows\\system32\\wscript.exe \"createShorcut.vbs\"");
    you will need a file called directories.ini with the following format:
    <directory that will hold the shortcuts>
    <directory 1>
    <directory 2>
    <directory n>
    END
    example
    --->file start<---
    c:\root
    c:\
    d:\
    f:\apps\
    g:\games\
    END
    --->file end<----
    import java.io.*;
    class winVirtualFolder
         public static void main (String args[]) throws IOException, InterruptedException
               File inFile = new File("directories.ini");
             FileReader fileReader = new FileReader(inFile);
             BufferedReader bufReader = new BufferedReader(fileReader);
             String str="";
                   String home="";
                   winVirtualFolder wVF=new winVirtualFolder();
             home= bufReader.readLine();
                   str=bufReader.readLine();
                   System.out.println("HOME DIR: "+home);
                   while (!str.equals("*END*"))
                        System.out.println("***STR: "+str);
                        wVF.createShortcuts(str,home);
                        str=bufReader.readLine();
         void createShortcuts(String path,String home) throws IOException, InterruptedException
              File directory= new File(path);
              String[] listing =directory.list();
              File[] fileListing =directory.listFiles();
              String[] directories= new String[listing.length];
              for (int i=0;i<listing.length;i++)
                   System.out.print(listing);
                   if (fileListing[i].isDirectory())
                        System.out.println(" DIRECTORY");
              File outFile = new File("createShorcut.vbs");
              FileWriter fileWriter = new FileWriter(outFile);
                   BufferedWriter bufWriter = new BufferedWriter(fileWriter);
                        bufWriter.write("set WshShell = WScript.CreateObject(\"WScript.Shell\")\r\n");
                        bufWriter.write("set oShellLink = WshShell.CreateShortcut(\""+home+""+listing[i]+".lnk\")\r\n");
                        bufWriter.write("oShellLink.TargetPath = \""+path+""+listing[i]+"\\\"\r\n");
                        bufWriter.write("oShellLink.Description = \""+listing[i]+"\\\"\r\n");
                        bufWriter.write("oShellLink.Save\r\n");
              bufWriter.close();
                        sleep(1000);
                        Runtime.getRuntime().exec("c:\\winnt\\system32\\wscript.exe \"createShorcut.vbs\"");
                   else System.out.println("");
         void sleep (long time)
              long waitValue=System.currentTimeMillis()+time;
              while (System.currentTimeMillis()<waitValue){}

    I have over come my problem by creating a seperate script for each shortcut first and then running the scripts later. This does mean that there needs to be space for the temporary script files... but since each of those are under 1K each i do not suppose that it is much of an issue. It has however remakably increased performance by over 100 fold!
    here is the code if anyone is interested:
    import java.io.*;
    import java.util.*;
    class winVirtualFolder
         public static void main (String args[]) throws IOException
               File inFile = new File("directories.ini");
             FileReader fileReader = new FileReader(inFile);
             BufferedReader bufReader = new BufferedReader(fileReader);
             String str="";
                   String home="";
                   int count=0;
                   winVirtualFolder wVF=new winVirtualFolder();
             home= bufReader.readLine();
                   str=bufReader.readLine();
                   System.out.println("Home Directory: "+home);
                   Vector createdDirectories = new Vector();
                   File directory= new File(home);
                   String[] listing =directory.list();
                   for (int i=0;i<listing.length;i++)
                        if (wVF.isAlink(listing))
                             createdDirectories.add(listing[i].substring(0,listing[i].length()-4));
                             count++;
                   int startCount=count;
                   while (!str.equals("*END*"))
                        System.out.println("Creating shortcuts scripts of directories from "+str);
                        count=wVF.createScripts(str,home,createdDirectories,count);
                        str=bufReader.readLine();
                   System.out.print("Running Scripts");          
                   wVF.runScripts(startCount,count,home);
                   int dirCount=0;
                   File file;
                   while (dirCount<count-1)
                        dirCount=0;
                        String str1;
                        for (int i=0;i<createdDirectories.size();i++)
                             str1=(String) createdDirectories.get(i);
                             file = new File(home+""+str1+".lnk");
                             if (file.exists()) dirCount++;
                        System.out.print(".");
                        wVF.sleep(100);
                   System.out.println("Done!");
                   System.out.println("Deleting Scripts");
                   wVF.deleteScripts(startCount,count,home);
         int createScripts(String path,String home,Vector createdDirectories, int count) throws IOException
              File directory= new File(path);
              String[] listing =directory.list();
              File[] fileListing =directory.listFiles();
              String[] directories= new String[listing.length];
              for (int i=0;i<listing.length;i++)
                   if (fileListing[i].isDirectory())
                        int no=0;
                        String number="";
                        while(exists(listing[i]+""+number,createdDirectories))
                             no++;
                             number="-"+no;
                        createdDirectories.add(listing[i]+""+number);
                        File outFile = new File(home+"createShorcut"+count+".vbs");
              FileWriter fileWriter = new FileWriter(outFile);
                   BufferedWriter bufWriter = new BufferedWriter(fileWriter);
                        bufWriter.write("set WshShell = WScript.CreateObject(\"WScript.Shell\")\r\n");
                        bufWriter.write("set oShellLink = WshShell.CreateShortcut(\""+home+""+listing[i]+""+number+".lnk\")\r\n");
                        bufWriter.write("oShellLink.TargetPath = \""+path+""+listing[i]+"\\\"\r\n");
                        bufWriter.write("oShellLink.Description = \""+listing[i]+"\\\"\r\n");
                        bufWriter.write("oShellLink.Save\r\n");
              bufWriter.close();
                        count++;
              return count;
         void runScripts(int startCount,int count,String home) throws IOException
              for (int i=startCount;i<count;i++)
                   Runtime.getRuntime().exec("c:\\winnt\\system32\\wscript.exe \""+home+"createShorcut"+i+".vbs\"");
         void deleteScripts(int startCount,int count,String home) throws IOException
              for (int i=startCount;i<count;i++)
                   File outFile = new File(home+"createShorcut"+i+".vbs");
                   outFile.delete();
         void sleep (long time)
              long waitValue=System.currentTimeMillis()+time;
              while (System.currentTimeMillis()<waitValue){}
         boolean exists(String str,Vector createdDirectories)
              for (int i=0;i<createdDirectories.size();i++)
                   if (str.equals((String) createdDirectories.get(i))) return true;
              return false;
         boolean isAlink(String str)
              if (str.endsWith(".lnk"))
                   return true;
              return false;

  • How to check a text file is already opened by another process

    Hi All,
      We are facing a requirement to check a simple text file that has been already opened by some other process using java programming.We are using simple file reading concepts to read the content of those text file
      For eg: Let us take sample.txt in any of the system location which is manually opened and we need to check that sample.txt is opened or not using java programming.
                  If it is not opened by any process then only we should  read that file otherwise we shouldn't.
    ANY GUIDANCE WILL BE HELPFUL...
    Thanks & Regards,
    Rumeshbabu

    Hi Christian,
    Thanks. Our scenario is...
    1. We have log files(in.txt) which is scheduled everyday for tracking and the scheduler will be writing the file ,it will be closed by night 11.
    2.So in case if we write any java code to access that log file(using  io file concept in java) we need access to that log file from our standalone java program only after night 11 0 clock.
    3.So we should check a condition whether that log file has been already used by some other process.
    Thanks & Regards.
    Rumeshbabu

  • How to check & unzip zip file using java

    Dear friends
    How to check & unzip zip file using java, I have some files which are pkzip or some other zip I want to find out the type of ZIp & then I want to unzip these files, pls guide me
    thanks

    How to check & unzip zip file using java, I have
    ve some files which are pkzip or some other zip I
    want to find out the type of ZIp & then I want to
    unzip these files, pls guide meWhat do you mean "other zip"? Either they're zip archives or not, there are no different types.

  • How to check if "create session" is being audited in the aud$

    Specifically, how do the determine if "create session" is being audited? Assume audit_trail=db_extended, audit_sys_operations=true and audit_file_dest has been set. Please specifically how to check if "create session" is being audited. Thanks

    SQL> connect test/test
    Connected.
    SQL> connect / as sysdba
    Connected.
    SQL> select username, action_name, to_char(timestamp,'DD/MON HH24:MI') from dba_audit_trail where action_name like 'LOG%';
    USERNAME                       ACTION_NAME                  TO_CHAR(TIMESTAMP,'DD/MONHH24
    TEST                           LOGON                        10/JANV. 19:32
    TEST                           LOGOFF                       10/JANV. 19:32
    SQL> select to_char(sysdate,'DD/MON HH24:MI') from dual;
    TO_CHAR(SYSDATE,'DD/MONHH24:M
    10/JANV. 19:33

  • How to check Whether the File is in Progress or used by some other resource

    Hi All,
    I am retrieving a file from the FTP server using Apache commons FTP.
    I need to check whether the file is fully retrieved or in progress.
    for now i can able to use the file which is partially retrieved. it is not throwing any file sharing exception or i am unable to find whether it is in progress.
    How to check whether the file is in progress ? or The file is accessed by some other resource ?
    Pls Help me.
    Thanks,
    J.Kathir

    Hi Vamsi,
    Explicitly such kind of requirement has not been catered and i dont think you would face a problem because any application that is writing to a file will open the file in the read only mode to any other simultaneous applications so i think your concerns although valid are already taken care off .
    In the remote case you still face a problem then as a work around. Tell the FTP administrator to set the property to maximum connections that can be made to ftp as one. I wonder if you have heard of the concept of FTP handle , basically the above workaround is based on that concept itself. This way only one application will be able to write.
    The file adapter will wait for its turn and then write the files.
    Regards
    joel
    Edited by: joel trinidade on Jun 26, 2009 11:06 AM

  • [svn] 3918: apparently I needed to check it that file was being copied in other places! This should fix the build .

    Revision: 3918
    Author: [email protected]
    Date: 2008-10-27 16:52:01 -0700 (Mon, 27 Oct 2008)
    Log Message:
    apparently I needed to check it that file was being copied in other places! This should fix the build.
    Modified Paths:
    flex/sdk/branches/3.2.0/build.xml

    in the future, buy this, this is what the Pros use:
    for drops, accidents, spills, loss, or theft, purchase a TYPE of insurance called "inland marine insurance"
    roughly $30 per year for a device(s) with 0 deductible, used same for over 20 years, same insurance the pros use on their portable devices.
    very cheap, very useful insurance, most people dont know about same.
    http://en.wikipedia.org/wiki/Inland_marine_insurance

  • JavaScript: How to check if a file exists.

    Hello Everybody,
    Can you tell me how to check if a file exists using JavaScript and Internet Explorer.
    Browsing on this website I could read about the command "f.exists()" and it was necessary to include "java.io.*".
    Should I use this same command and should I include the same files? Or are there other files and other commands?
    Thanks in advance.

    sorry ya. there is no command to check whether a file exists using javascript. The following code says the object name and value. But it can't say whether the file exists in the harddisk or .. Javascript cannot access database and system resources. If the file exists or not can be checked through the application (ASP, CFML, ..) you are using.

  • How to check whether a file exist in the program folder or not?

    Hi guys,
    how to check whether a file exist in the program folder or not? Let is say i recieve a file name from user then i want to know if the file is there not and act on that base.
    abdul

    Look at the class java.io.File and the .exists() method:
    http://java.sun.com/j2se/1.4/docs/api/java/io/File.html

  • How to check-in multiple files with same name having different revision num

    Hi
    Can anyone please tell me, how to check-in multiple files with the same name with different revision number using RIDC API.
    For eg:
    First I will check-in a file(TestFile.txt) into a content server with revision number 1 using RIDC API in ADF application. Then after some time, will modify the same file(TestFile.txt) and check-in again. I tried to check-in same file multiple times, however first time its checking-in correctly into server showing revision as 1, while checking-in same file again, its not giving any errror message, and also its not reflecting in server. Only one file(TestFile.txt) is reflecting in server.
    How to implement this functinality using RIDC API? Any suggestions would be helpful.
    Regards
    Raj
    Edited by: 887680 on Mar 6, 2013 10:48 AM

    Hi Srinath
    Thanks for your response. Its not cloning, its like check-in file first, then check-out the file and do some editing and then again upload the same file with different revision number using RIDC. I got the solution now.
    Regards
    Raj

  • [HTML]SignTool Error: The file is being used by another process.

    Hello,
    I receive this error from building a JavaScript app on a build server:
    SignTool Error: The file is being used by another process.
    This reproduced when building on local machine, and goes away after building again. However, our company uses gated builds so the first failure will stop an entire 2.1 hour build and I can't ship the product.
    The instruction to launch SignTool is located in external files so I can't disable it, run it twice, or run it in a while loop until succeeds, ignoring failures. I have to get it to work right the first time. I looked on MSDN, and there are other people
    who had this problem and never solved it.
    https://social.msdn.microsoft.com/Forums/vstudio/en-US/5871d64c-e178-4f5c-85cd-a603fe56d6c7/signtask-signtool-error-the-file-is-being-used-by-another-process?forum=msbuild
    http://www.codeproject.com/Questions/275454/Can-anyone-help-me-with-Signtool-Setup-Deployment
    http://qualapps.blogspot.in/2006/12/code-signing.html
    The only clue I have is our solution having build configurations that aren't called "Debug" and "Release", which have been cloned from Debug/Release and have WinRT apps building. If the build script for WinRT depends on anything being
    called "Debug" and "Release" it wouldn't work correctly.
    In any case, there is no documentation for SignTool that mentions this error - how do I fix it?

    Hi TripleRectified,
    >> If the build script for WinRT depends on anything being called "Debug" and "Release" it wouldn't work correctly
    What's you version of Visual Studio, on my side, in the Visual Studio 2013 Update 4, I created a new configuration(Copy Settings from "Debug") to build a WINJS project, but I can't see the exception you mentioned.
    >>This reproduced when building on local machine, and goes away after building again
    Does it happen on all local machines? We need to exclude environment facts first, for example: Tool, OS etc.
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Communication Channel marked all files as being read on FTP

    The Mailbox FTP has all the files flagged as being read when a single file is read through a communication channel.  I manually unflagged the status field so all files had a status of N so none were pulled.  I had 14 files for this test flagged as N.   I turned off all our CCu2019s.  I activated one that was pulling the last file in the list based on the Service Ref# which is unique file name.  I refreshed the dir of the FTP several times as the CC was running.  One by one as the flag was changed to Y (file read) from top to bottom.  It only took a second for each one until it got to three very large files and the status stopped while it was reading the file.  After a minute it continued to change the flag until it read the last one.   All 14 files on the ftp now had the status flag changed to Y.  It appears it actually read the file content one by one and set the flag until it was done.  Do you have any ideas why it would do this?  From a dos prompt I donu2019t have any of these issues so Iu2019m guessing itu2019s something unique in the SAP FTP adapter that is doing it?
    From a dos prompt I can successfully do a get 003520827870964903 c:data.txt and it will only update that ST flag for that one file as being read.  I can also do a get %EDT39A22%W_Z1JI4960 c:data.txt  and it will only flag the four files as being read that have that Mailbox/APRF value.  Now I'm trying to get my CC to do the same but no matter what I try it marks all six files as being read.   I have in my source directory %EDT39A22%W_Z1JI4960 and * for a file name and this will mark all files as being read when activated.   I have entered 003520827870964903 for a file name to further qualify and it still marks all files as being read.  It seems to be getting the file I want cause when I view the communication channel monitor it shows the right data in the payload but it always refers to another file for the archive / delete / test option from the processing tab.  There are no problems having a CC write a file out using similar parms for Mailbox/APRF, but trying to read a single file using the Service Ref # or a collection of files using a Mailbox/APRF mask seem to update the status for all files as being read.  Any suggestions are welcome.
    Mailbox ID           St    APRF                SNRF              Service Ref. #
    CMS                  N     CCR_GRIEF           filekh5LhC0000    003520599937481654
    CMS                  N     CLAIM_STLMNTS       fileza2TBr0004    003520769829611413
    EDT39A22             N     W_Z1JI4960          ileh3s0e60000     003520827846664146
    EDT39A22             N     W_Z1JI4960          fileUfXjR     003520827868994913
    EDT39A22             N     W_Z1JI4960          filePDFfKP0000    003520827870124419
    EDT39A22             N     W_Z1JI4960          fileQ7RFdR0000    003520827870964903
    Edited by: Kenbrown on Jul 28, 2011 9:10 PM
    Edited by: Kenbrown on Jul 28, 2011 9:13 PM

    Have you installed any apps that auto display the emails when they come in? If so the auto read feature may be triggering this, I had a app at one time that showed my emails in the preview window and it made the emails be listed as read... I would check your apps and make sure you are not using something like this unknowingly.

  • How to erase archives protected files by Acrobat Reader

    Hi,
    I would like to know how to erase archives protected files of Acrobat Reader and install by Acrobat Reader and not my self..
    After a download, directly on the Website of Adobe of an install file of Acrobat Reader for the french version 10.1.4 for Windows XP Service Pack 3 named : Install_reader10_fr_gtbd_chrd_dn_aaa_aih.exe  , I scanned the file with Avast and it told me that it couldn't scan some files protected by a past word..
    I notice the same problem for Acrobat Reader version 11.0.03
    The problem is that I had already Intall this version Acrobat Reader and now it is impossible for me to erase those files.
    Would anybody have a solution for this problem?
    Thank you,
    bedmich

    It might be best to check in the Reader forum.

  • How do I stop my SMSs from being read by other family members?

    How do i stop my SMSs from being read by other family members?

    batterseauser wrote:
    They r receiving my text messages onto their iPhones and they are not allowing me access to stop this
    Change the password for your AppleID you used to set up iMessaging, and do not tell them the password.  Tell them to get their own AppleIDs for use with their own iMessage accounts.

Maybe you are looking for