c# - How to get file name from a specified folder? -
i want file name resides under specified folder.
i.e. there file stored under 2 folders first\second\test.txt
want have path of parent directory of file first\second\
in program. want file name residing under directory "second" using code.
please help me.
the next trick if want 1 file.
using system.io; using system.linq var file = directory.getfiles("c:\\first\\second\\").firstordefault(); if (file != null) { var filename = path.getfilename(file); }
the next file names:
using system.io; using system.linq var files = directory.getfiles("c:\\first\\second\\"); var filenames = files.select(f => path.getfilename(f));
c# asp.net
No comments:
Post a Comment