vb.net - How do I read each text file from directories -
basically in program there form , form b. in form a, user adds information , when clicks on button, folder unique id created , text file created in folder. whenever user wants save more information, each time so, folder gets created , text file gets saved inside it.
in form b, i've added listview , set style details. want every time form loaded, program read each text file directories saved in e.g. c:/ , add read items. listview has these columns: username, description
, me populate items relevant column, i'd like:
listview1.items.add(new listviewitem({"username", "description"}))
how can make reads each text file folders created , populates listview columns want?
i managed solve problem adding loops.
public sub readfile() each dir string in directory.getdirectories(getfolderpath(specialfolder.applicationdata) + "\folder\sub-folder\") dim file1 string() = directory.getfiles(dir, "file1") dim file2 string() = directory.getfiles(dir, "file2") dim file3 string() = directory.getfiles(dir, "file3") dim file4 string() = directory.getfiles(dir, "file4") dim finalfile1 string dim finalfile2 string dim finalfile3 string dim finalfile4 string each finalfile1 in file1 using readfile1 streamreader = new streamreader(finalfile1) dim line string = readfile1.readline end using next each finalfile2 in file2 using readfile2 streamreader = new streamreader(finalfile2) dim line1 string = readfile2.readline end using next each finalfile3 in file3 using readfile3 streamreader = new streamreader(finalfile3) dim line2 string = readfile3.readline end using next each finalfile4 in file4 using readfile4 streamreader = new streamreader(finalfile4) dim line3 string = readfile4.readline end using next listview1.items.add(new listviewitem({addname, addusername, addwebsite, adddescription})) next end sub
what i've added string find file name. read each folder there , added relevant column.
Comments
Post a Comment