电子商务物流网站建设规划方案,企业推广网站的方法,攀枝花建设网站,wordpress php.inivb.net-如果不存在#xff0c;如何在VB中创建文件夹#xff1f;我为自己编写了一个小小的下载应用程序#xff0c;以便我可以轻松地从服务器上获取一组文件#xff0c;然后将它们全部放入带有全新安装的Windows的新PC上#xff0c;而无需实际运行网络。 不幸的是#xff…vb.net-如果不存在如何在VB中创建文件夹我为自己编写了一个小小的下载应用程序以便我可以轻松地从服务器上获取一组文件然后将它们全部放入带有全新安装的Windows的新PC上而无需实际运行网络。 不幸的是我在创建要放入的文件夹时遇到了问题不确定如何处理。我希望我的程序将应用程序下载到program files\any name here\因此基本上我需要一个函数来检查文件夹是否存在如果不存在它将创建该文件夹。12个解决方案149 votesIf(Not System.IO.Directory.Exists(YourPath)) ThenSystem.IO.Directory.CreateDirectory(YourPath)End IfQuintin Robinson answered 2020-01-27T14:28:41Z22 votes在System.IO下有一个名为Directory的类。请执行下列操作If Not Directory.Exists(path) ThenDirectory.CreateDirectory(path)End If这将确保该目录在那里。MagicKat answered 2020-01-27T14:29:05Z11 votes由于问题未指定.NET因此它应在VBScript或VB6中工作。Dim objFSO, strFolderstrFolder C:\TempSet objFSO CreateObject(Scripting.FileSystemObject)If Not objFSO.FolderExists(strFolder) ThenobjFSO.CreateFolder(strFolder)End IfRick answered 2020-01-27T14:29:25Z10 votes试试System.IO.DirectoryInfo类。来自MSDN的示例Imports SystemImports System.IOPublic Class TestPublic Shared Sub Main() Specify the directories you want to manipulate.Dim di As DirectoryInfo New DirectoryInfo(c:\MyDir)Try Determine whether the directory exists.If di.Exists Then Indicate that it already exists.Console.WriteLine(That path exists already.)ReturnEnd If Try to create the directory.di.Create()Console.WriteLine(The directory was created successfully.) Delete the directory.di.Delete()Console.WriteLine(The directory was deleted successfully.)Catch e As ExceptionConsole.WriteLine(The process failed: {0}, e.ToString())End TryEnd SubEnd ClassGuy Starbuck answered 2020-01-27T14:29:49Z5 votesVB.NET System.IO.Directory.Exists(字符串路径)Chris Bilson answered 2020-01-27T14:30:09Z5 votes试试这个Imports System.IO和Directory.CreateDirectory(TheFolderName)(您可能需要Imports System.IO)GEOCHET answered 2020-01-27T14:30:33Z4 votesDirectory.CreateDirectory()应该这样做。[http://msdn.microsoft.com/zh-cn/library/system.io.directory.createdirectory(VS.71).aspx]另外在Vista中除非您以管理员身份运行它否则您可能无法直接写入C :所以您可能只想绕过它并在C的子目录中创建所需的目录(我想说的是 无论如何都要遵循的一个好习惯-令人难以置信的是有多少人将废话扔到C上希望能有所帮助。Mostlyharmless answered 2020-01-27T14:31:04Z4 votes(导入System.IO)if Not Directory.Exists(Path) thenDirectory.CreateDirectory(Path)end ifWayne answered 2020-01-27T14:31:23Z3 votesIf Not Directory.Exists(somePath) thenDirectory.CreateDirectory(somePath)End IfSiddharth Rout answered 2020-01-27T14:31:39Z1 votes您应该尝试使用文件系统对象或FSO。 属于该对象的方法有很多它们可以检查文件夹是否存在以及创建新文件夹。Dave answered 2020-01-27T14:31:59Z0 votes我知道它是如何工作的创建对话框的过程将是什么该对话框允许用户命名文件夹并将其放置在所需的位置。干杯answered 2020-01-27T14:32:24Z0 votes只是这样做Dim sPath As String Folder path hereIf (My.Computer.FileSystem.DirectoryExists(sPath) False) ThenMy.Computer.FileSystem.CreateDirectory(sPath /)ElseSomething else happens, because the folder existsEnd If我将文件夹路径声明为String(sPath)这样如果您多次使用它则可以轻松更改它也可以通过程序本身对其进行更改。希望能帮助到你-nfell2009BaeFell answered 2020-01-27T14:32:57Z