A skeleton

blumonde

Well-known member
Joined
Jul 26, 2005
Messages
68
Programming Experience
Beginner
Happy New Year to all,

Could someone please show me a skeleton of code on how to write a DLL file where its tasks are to open a file to extract the data and then creates an object of the obtained data and passes it on to an application?

Please advise,

Thanks.

blumonde
 
Happy New Year to you as well!

I don't have the code but I can outline the steps needed...

1] Create a Class Library project
2] Create a class in the library to read file data.
3] If this file is xml then you can use some of the system.xml namespace classess/methods.
4] If this is just a flat file then read the data using system.io classes.
5] I'd read the data into a dataset object and that would allow you to save the data to xml easily or update a database easily. If your going to pass this object data to another application or class then the dataset will pass via http easy as xml.

Hope this gets you kick started. :)
 
Create a new Class Library project, add this code:
VB.NET:
public Class myDll
Shared Function GetFileContents(ByVal FullPath As String, _
Optional ByRef ErrInfo As String = "") As String
Try
Dim objReader As New System.IO.StreamReader(FullPath)
Dim strContents As String = objReader.ReadToEnd()
objReader.Close()
Return strContents
Catch Ex As System.Exception
ErrInfo = Ex.Message
End Try
End Function
End Class

In application, add reference to your compiled DLL, access function there like this:
VB.NET:
Dim str As String = myDLL.GetFileContents("C:\textfile.txt")
 
Back
Top