Solved

2 Apps access the same directory.

Posted on 1998-09-22
3
147 Views
Last Modified: 2010-04-30
I am writing 2 separate programs that need to access the same directory. The first application will save the files in the directory. The second application will have to copy all the files in the same directory to the remote machine and delete it. The problem is there is a chance that the first application is still trying to write a file and the second  application have reading the partial of it to the remote machine. What is the best method to accomplish this?

My current idat is to have a status file. I think maybe I can have a dummy file with 0 byte to indicate which application is using the directory. If the first application lock this file then the second app will wait until this file is unlock. When the second app gain control by locking the dummy file, the first application will wait. However I don't know how to  lock the file or how to check if the file is currently locked or not. Please suggest me on this and also if you have any better idea.
0
Comment
Question by:akarapol
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 

Author Comment

by:akarapol
ID: 1436167
Edited text of question
0
 
LVL 2

Accepted Solution

by:
swilt earned 50 total points
ID: 1436168
Public Function bIsFileReallyThere(ByVal sFile As String) As Boolean
    On Error GoTo EHbIsFileReallyThere
   
    Dim bRet As Boolean
    Dim fh As Integer
   
    bRet = True
    fh = FreeFile
    Open sFile For Input As #fh
    Close #fh
    bIsFileReallyThere = bRet
    Exit Function
   
EHbIsFileReallyThere:
    bRet = False
    Resume Next
End Function
0
 
LVL 14

Expert Comment

by:waty
ID: 1436169
akarapol,

We do exactly the same thing here. here is the process :

We have an application wich creates files like b******.sp
Once the file is completely written on disk, the application write a file like c******.sp (****** is the same for both files)
We have another app wich looks in the directory for files begining by "c". Once the application find a file, it knows that a "b" files is there, and do is process.

If you want, I can post you code here.
0

Featured Post

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question