visual studio 2010 - Reading text file and skipping blank lines in vb.net -


i have below code appends content of text file richtextbox1.

dim filename = new directoryinfo(path.combine(environment.getfolderpath(environment.specialfolder.desktop), "client history\" & textbox1.text))  each clientdetailscht fileinfo in filename.getfiles("*.cht", searchoption.topdirectoryonly)     richtextbox1.appendtext(file.readalltext(clientdetailscht.fullname)) next ' send printing sub 

this works fine.

the problem having text file contains blank lines , skip blank lines code appends text richtextbox.

how can re-write code achieve this? using visual basic 2010.

you can loop through lines , skip ones blank. following code skips lines empty or contain white space. if want skip empty lines, change isnullorwhitespace isnullorempty.

dim filename = new directoryinfo(path.combine(environment.getfolderpath(environment.specialfolder.desktop), "client history\" & textbox1.text))  each clientdetailscht fileinfo in filename.getfiles("*.cht", searchoption.topdirectoryonly)     each line string in file.readalllines(clientdetailscht.fullname)         if not string.isnullorwhitespace(line) richtextbox1.appendtext(line & vbcrlf)     next next ' send printing sub