text files - how to Write Content into textfile in vb.net -


i created validccc.txt , need write content text file, content shown below

content :

00   a0 00   a1 00   a2 10   a0 10   a1 

my code follows :

filepath = filepath + "\" + strsubmenu + "\"  if (not system.io.directory.exists(filepath))     system.io.directory.createdirectory(filepath) end if  filepath = filepath + "matrix\" if (not system.io.directory.exists(filepath))     system.io.directory.createdirectory(filepath)  end if  filepath = filepath + "validccc.txt" if (not system.io.directory.exists(filepath))     file.create(filepath) end if  file.writealltext(filepath, string.empty) dim objwriter new system.io.streamwriter(filepath, true)  each customeritem listitem in customercodedvlistbox.items     each cccitem listitem in ccclistbox.items         objwriter.writeline(customeritem.tostring() + space(4) + cccitem.tostring())     next next  

i have 2 listboxes combination of listbox seleted values should write textfile. before writing content if validccc.txt exists need clear content or overwrite new content...

this working ...

 filepath = filepath + "validccc.txt"                 dim objwriter streamwriter                  dim sb new stringbuilder                 each customeritem listitem in customercodedvlistbox.items                     if customeritem.selected                         each cccitem listitem in ccclistbox.items                             if cccitem.selected                                 sb.append(customeritem.tostring() + space(4) + cccitem.tostring())                                 sb.append(environment.newline)                              end if                         next                     end if                 next                  if (not system.io.directory.exists(filepath))                     objwriter = file.createtext(filepath)                     objwriter.writeline(sb.tostring())                     objwriter.close()                 end if 

Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -