.net - adding files to listview in C# -
i have listview , "add" button,when click on add should able browse files in computer, select files , when click ok or open, file list should added in listview...how that...is listview correct or other alternative...?
listview should fine file listing. aware longer file paths difficult see (have horizontally scroll bad!) if gonna add full path list. can toy idea of other representation like:
file.txt (c:\users\me\documents) c:\users\..\file.txt etc
as far doing using code concerned, need use openfiledialog control let user choose files.
var ofd = new openfiledialog (); //add extension filter etc ofd.filter = "txt files (*.txt)|*.txt|all files (*.*)|*.*" ; if(ofd.showdialog() == dialogresult.ok) { foreach (var f in openfiledialog1.filenames) { //transform list better presentation if needed //below code adds full path list listview1.items.add (f); //or use below code add file names //listview1.items.add (path.getfilename (f)); } }
Comments
Post a Comment