vb.net - Create folder from textbox input in visual basic -


I want to create a folder in VB with a textbox Like I have a "browse" button, a textbox1 and "create folder" buttons, I want to browse a folder on the file system where users want to create folders and select the selected location as < Should be copied to code> textbox1 , then user should click on the "Create Folder" button; If the folder does not exit, then a dialog should say that the folder has been created successfully if the folder exists, then it should say, the folder already exists.

All help is very much appreciated Thanks .

This is the code that I'm trying to write yet:

  Importing System IO public square at 1 dim folder name string CreateFolder (private function) FolderName = TextBox1.Text My.Computer.FileSystem.CreateDirectory ( "" & amp; FolderName & amp; "") are My.Computer.FileSystem.DirectoryExists ("" & FolderName & amp; "") = False Throw New Exception ("The specified path does not exist") Otherwise My.Computer.FileSystem.DirectoryExists ("" & "FolderName & amp; Could not be made, because it already exists ") then throw a new exception (" ") ending in the end. Function Private Sub FolderCreate () are not My.Computer.FileSystem.DirectoryExists CreateFolder () ( "" & amp; FolderName & amp; "") again failed to throw new Exception ( "Folder.") End If End Sub Private Sub Button1_Click (ByVal as the System.Object, ByVal e as System.EventArgs) handles Button1.Click FolderCreate () End sub private sub browse_Click (object, EventArgs e) as handle browse.C lick so (FolderBrowserDialog1.ShowDialog () = Windows.Forms.DialogResult.OK) then TextBox1.Text = FolderBrowserDialog1.SelectedPath end if end Sub end class  

So when they browse a directory, if you are expecting the user to use the" Create a new folder "button, that Folderbraujhr dialog appears? From your explanation, they will navigate to the folder using FolderBrowserDialog and click the button to create a directory that will always be present (unless they type additional folder names in the textbox).

  Importing System. IO Public Class Form 1 New Folder as Private Folder Brochure Dialog 1BrowserDialogs Personal Sub Button 2_Click (Objects as Sender, and EventArgs) Button 2 Handles Click (FolderBrowserDialog1.ShowDialog () = Windows.Forms.DialogResult.OK) then TextBox1.Text = FolderBrowserDialog1.SelectedPath terminate End Sub Private Sub Button1_Click (as the object, handles e EventArgs) Button1.Click My.Computer.FileSystem.DirectoryExists (Me.TextBox1.Text) then MessageBox.Show ( "selected directory already exists!") try or My.Computer.FileSystem.CreateDirectory (Me.TextBox1.Text) MessageBox.Show ( "Selected directory has been created!") Show Exception Message box as Catch ("Could not create directory! Error:" and pre-message, "no Error creating Rdeshika. "_ Message box button. OK, the message box icon. Error) and and and and and and and and all Class  

Comments

Popular posts from this blog

c# - SignalR: "Protocol error: Unknown transport." when navigating to hub -

c# - WPF Expander overlay used in ItemsControl -

class - Kivy: how to instantiate a dynamic classes in python -