I am creating an application that downloads a file, copies the old file to c:/sdk/backup (after check if this folder exists) then it moves the downloaded file to the location of the original file.
The location of the original file is variable, the user has 2 options: leave the default path in a textbox or choose openfiledialog to put a new path in the same box.
Before moving the downloaded file to the original location I would like to check if indeed this path exists. If I now change the default location to Z:/blablabla then the program crashes with an I/O exeption.
I now use this:
(dutch for filename)Code:Dim bestandsnaam = TextBoxLocatie.Text.Substring(TextBoxLocatie.Text.LastIndexOf("\") + 1)
Now I would like to do something like this:
Unfortunately such coding does not exist. Can anyone help me with this?Code:Dim ftdlocatiedir As String = TextBoxLocatie.Text.Substring(TextBoxLocatie.Text - bestandsnaam)
the goal is to make this work (now I do not have a valid string for the ftdlocatiedir).
Thanks in advance (!).Code:If Not IO.Directory.Exists(ftdlocatiedir.Text) Then MessageBox.Show("Not a valid directory to download to, please pick a valid directory", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error) Return Else File.Copy(downloadlocatie, ftdlocatie) LabelFinish.Visible = True LabelFinish.Text = "Nieuwe post bestand geplaatst, Start FTD!" End If




Reply With Quote