[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

2 Apps access the same directory.

Posted on 1998-09-22
3
Medium Priority
?
151 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 100 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

649 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