vb.net - How to move all files and folders from current directory to another directory excluding a folder named "My Folder" in vb? -



vb.net - How to move all files and folders from current directory to another directory excluding a folder named "My Folder" in vb? -

i want move files , folders current directory directory excluding folder named "my folder". want know how can vb?

not tested might helpful anyway:

dim currentdir = directory.getcurrentdirectory() ' or whatever phone call current dim targetdir = path.combine(currentdir, "target-directory") directory.createdirectory(targetdir) dim alldirs = dir in directory.enumeratedirectories(currentdir, "*.*", searchoption.alldirectories) not path.getfilename(dir).equals("my folder", stringcomparison.invariantcultureignorecase) each dir string in alldirs seek dim targetpath string = path.combine(targetdir, path.getfilename(dir)) directory.move(dir, targetpath) grab ex exception ' log or whatever, here ignore , go on ... end seek next 'now move rest of files in troot folder dim filesinroot = file in directory.enumeratefiles(currentdir, "*.*", searchoption.topdirectoryonly) each file string in filesinroot seek dim targetpath string = path.combine(targetdir, path.getfilename(file)) io.file.move(file, targetpath) grab ex exception ' log or whatever, here ignore , go on ... end seek next

vb.net visual-studio visual-studio-2013

Comments

Popular posts from this blog

javascript - THREE.js reposition vertices for RingGeometry -

javascript - I need to update the text of a paragraph by inline edit -

assembly - What is the addressing mode for ld, add, and rjmp instructions? -