vb.net - How to use an external config .ini file in VB .Net? -


i have program in vb.net uses winsock. want make external config in .ini file. program works when i'm running it, when want lister port error.

here function reads .ini file:

public function getsettingitem(byval file string, byval identifier string) string     dim s new io.streamreader(file) : dim result string = ""     while (s.peek <> -1)         dim line string = s.readline         if line.tolower.startswith(identifier.tolower & ":")             result = line.substring(identifier.length + 2)         end if     loop     return result end function 

this winsock listen port:

private sub button1_click(byval sender system.object, byval e system.eventargs) handles button1.click     axwinsock1.localport = getsettingitem("d:\mainconfig.ini", "port")     axwinsock1.listen() end sub 

error

an unhandled exception of type 'system.invalidcastexception' occurred in microsoft.visualbasic.dll  additional information: conversion string "" type 'integer' not valid. 

where problem? how listen port in .ini files?


Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -