删除文件夹并包含文件 [英] Delete Folders and Containing Files

查看:66
本文介绍了删除文件夹并包含文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个很快速的问题。我的程序实际上下载了一个zip文件,然后将其解压缩到其桌面上。但是我需要一个卸载功能,该功能基本上是删除多个文件夹并包含文件。如何在vb.net中执行此操作?

I have a really quick question. My program actually downloads a zip file then extracts it onto their desktop. But I need an uninstall feature for it, which is basically deleting multiple folders and containing files. How can I do this in vb.net?

推荐答案

如果所有文件夹都包含在一个文件夹中,则应该

If all of your folders are contained in a single folder, it should be pretty straight forward.

Dim path As String = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) & "\YOURPATH"
System.IO.Directory.Delete(path, True)

这将删除您的根目录及其下的所有目录和文件。如果您的文件和目录不是全部都放在单个根目录中(例如本例中的 YOURPATH),则可以多次调用此命令。这将使您不必单独删除每个文件。

That will delete your root directory, and all the directories and files below it. You could just call this several times over if your files and directories are not all in a single root directory like "YOURPATH" in the example. This will spare you from having to remove each file individually.

这篇关于删除文件夹并包含文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆