Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 42220

Open a file from inside a DLL and use/close it outside results in "bad file name...

$
0
0
I've created a dll that contains alle my functions and procedures i've build over the last decades. Even old Clippercode has recently been converted to .NET and put into this dll. Most functions work like a charm, except functions that open files, like the one below which is in a Class.

Public Shared Function OpenOutput(ByVal Filename As String, Optional ByVal AllowExceptionThrowing As Boolean = False) As Integer
'#Open a file for sequential writing. Returns the filenumber.
Initialize()
'
Dim FileNR As Integer = FreeFile()
'
Try
FileOpen(FileNR, Filename, OpenMode.Output)
Catch ex As Exception
FileNR = 0
If AllowExceptionThrowing Then Throw
End Try
'
Return FileNR
'
End Function[/B][/B]


This function gets a new freefile(), opens the file for sequential writing and returns the filenumber if all goes well, or 0 in case of failure.

The odd thing is this:

it returns a value (e.g. 1)
The file *is* created
But when I use the filenumber outside the dll as in : PrintLine(FileNR, "Hello World") I get "Bad file name of number"

If I copy the code above into the application I'm building, it works as it should be working.


Can anyone shed some light on what is happening here ?

Thanks

Viewing all articles
Browse latest Browse all 42220

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>