Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 162
  • Last Modified:

Locking a file

I am using VB4.0 32-bits, and I wish to know how can I lock certain files from other user using it if
one user is already using it.

Something like microsoft word, where if I am already using docA.doc, and user B from another computer can only view this docA.doc but cannot modify it. However, I perfer that user B cannot even view it at all, if the file is being used.

Is there a way I can code it?
0
wsm
Asked:
wsm
  • 3
  • 2
  • 2
1 Solution
 
raygibbinsCommented:
In your code you could create a file called docA.loc when a user  opens docA.doc for the first time. This lock file could contain things like user name etc. When another user wants to open docA.Doc the program first look for docA.loc. If docA.loc exists then you could read it and display a messagebox showing who has it open.
Code would be
If Dir$("c:\temp\docA.loc")<>"" Then
     'Read the lock file and display messagebox
End If

When the docA.doc is closed then the program would delete the lock file
0
 
AjoyCommented:
you can use the key word app. This supports certain  properties out of which you can use the instance property.
if app.instance then don't run the file.
if this does not work then get back to me at atarafder@hotmail.com. i would be glad to help you
0
 
wsmAuthor Commented:
Ajoy,

I am not very sure what you are saying. Can you give a little bit more
details and example which I can look at?

I think raygibbins has given another good example. However, I do not wish to
create too many "temp" files just for this purpose, if possible.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
raygibbinsCommented:
My example is the similar to the way Microsoft and AutoDesk do it.
0
 
wsmAuthor Commented:
I notice that, but like I said before I do not wish to add any more "temp" files to the current directory. I have already added some other "temp" hidden files into that directory. Only when I cannot find any other solution to solve this then I will use this creating "temp" file.

I would really appreciate if you can give me any other ideas beside this one.
Thanx inadvance.
0
 
AjoyCommented:
wsm,
Before i can give you more details, Could you please tell me if your application is client/server based or a simple application.if your application isc/s based and the application runs on the server then what i said above can easily be implemented.
0
 
wsmAuthor Commented:
it is just a normal application that runs on win95. This should or might be a networked environment, but it is not a client/server application. If it is a networked environment, then those files are located at a shared directory
whereby users are allowed to access it. That is why I need some sort of codes
or function that will let people knows if that file is being used by another person.

 Hope u can understand what I am trying to say here.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now