1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

File Lock in ASP

Discussion in 'C#' started by inderpal, Aug 10, 2006.

  1. #1
    Hi All,
    SEMrush
    Is there any way to get a file lock in ASP so that no one else can write to file at that particular time and when I call releaseLock, the lock will be released?

    I would appreciate any help in this regard. Thanks in advance!!

    Best Regards,
    Inderpal Singh
     
    inderpal, Aug 10, 2006 IP
    SEMrush
  2. Nafai

    Nafai Peon

    Messages:
    105
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Sure. Use an application variable.

    
    if Application("FILELOCKED")<>"true" then
       Application("FILELOCKED")="true"
       'do stuff with the file
       Application("FILELOCKED")="false"
    end if
    
    Code (markup):
    To make it wait for the lock, instead of IF...THEN, use DO...LOOP.
    If you're going to have a lot of connections to your site, you need to make sure two people don't execute the filelock check at the same time, because both would show it was unlocked then both would try to lock it. To do that, you'll have to use Application.Lock.
     
    Nafai, Aug 10, 2006 IP