Click here to Skip to main content
15,867,568 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello,

I am getting subjected error while running FILEOPEN for ReadWrite.

Before this fucntion the same file was opened with Read access and then closed immediately, but still i am getting subjected error.

MAIN()

FileOpen(iImageFileNbr, strImageFile, OpenMode.Binary, OpenAccess.Read, OpenShare.Shared)
FileClose(iImageFileNbr)

'Below is the DLL function calling from main application.

Public Sub Append_Start(ByRef lStatus As Integer, ByRef strMsgText As String, ByRef intSorterId As Short)

'***********************************************************************
'Purpose:
'Inputs: None
'
'Outputs: Status
'************************************************************************
On Error GoTo AppendStartErr

'Open TXT file
giFileNumber = FreeFile
FileOpen(giFileNumber, gSorterObject(intSorterId).strPathName & "\" & gSorterObject(intSorterId).strDBName & ".NDP", OpenMode.Random, , OpenShare.Shared, cDatalen)

'Open FIM/RIM files
giFIMFileNbr = FreeFile
'ERROR IN BELOW LINE****************
FileOpen(giFIMFileNbr, gSorterObject(intSorterId).strPathName & "\" & gSorterObject(intSorterId).strDBName & ".FIM", OpenMode.Binary, OpenAccess.ReadWrite, OpenShare.Shared)


I am not sure why still i am getting this error eventhough the file got closed before reopen it again.

Is there any option to UNLOCK or RELEASE the file access from all other existing holders (processes) to open it again.

Waiting for your suggestions to fix this issue.

Thanks in advance.
Posted
Updated 7-Oct-15 7:23am
v2

1 solution

You said your code closes the file and then tries to open it again. No it didn't. You didn't close the file from the first time you opened it.

I don't care what your code says, it's the error that's telling you that your code is not doing what you think it is.

Seriously, you have to debug this code step-by-step to see EXACTLY what it's doing and that includes verifying the values of all variables involved on every line of code.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900