Indexing Services locks saved PDF Files on Server Folder. RRS feed

  • Question

  • User1677734741 posted

    I have desinged an ASP.NET Process that will recieve submitted PDF files from the Browser in Base64 String Format, convert them to Binary PDF Format and save the file on a dedicated Folder on the server.

    I have enabled Indexing Services on the Folder which has the PDF Files which is under Window Server 2003 R2 SP2.

    I am using .NET program to generate the PDF and save to a file.

    Just recently, I noticed that Indexing Service is locking some files forever, and the only way to remove the lock is to restart indexing services.

    I am getting this error from .NET when the file is locked (when it is already saved before, and to be overwritten again):

    The process cannot access the file .... because it is being used by another process.

    It seems to me that the lock on the file just hangs and no matter how long I wait, it will still be there. the only way to solve this problem is to stop/start the Indexing Services.

    I am just wondering if there is anything I can do programatically to work around this problem, for example, using .NET to stop and restart the Indxing Services, or schedule the indexing services to start during th enight only, .... any other idea ?

    Appreciate your help.


    Tuesday, May 3, 2011 10:32 AM


  • User1677734741 posted

    Ok, it was easy, I just added the following Sub:

        Public Sub RestartIndexingServices()
            Dim sc As New ServiceController("CISVC")
            Dim theCount As Integer = 0
            If sc.Status.Equals(ServiceControllerStatus.StartPending) Or sc.Status.Equals(ServiceControllerStatus.Running) Then
                    If sc.Status.Equals(ServiceControllerStatus.StartPending) Or sc.Status.Equals(ServiceControllerStatus.Running) Then
                    End If
                    theCount += 1
                Loop Until sc.Status.Equals(ServiceControllerStatus.Stopped) OrElse sc.Status.Equals(ServiceControllerStatus.StopPending) OrElse theCount >= 3
                If sc.Status.Equals(ServiceControllerStatus.Stopped) Or sc.Status.Equals(ServiceControllerStatus.StopPending) Then
                End If
            End If
        End Sub


    Now things are much better.


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, May 4, 2011 4:19 AM