Hi

I have made a program that i would like to be able to move from PC to PC; at the moment i would have to change the string directories within the program for each PC i would like top run it on.

By having the user select their drive letter and type their account name into a text box could this be implemented into a directory.

Below is the code, as i was hoping it was coded (lol never is tho).

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim Filename As String = ("*.torrent")
        Dim HDDLocation As String = TextBox1.Text
        Dim AccountName As String = textbox2.text
        If System.IO.File.Exists((HDDLocation)"documents and settings", (AccountName), (Filename)) = True Then
            Try
            My.Computer.FileSystem.DeleteFile((HDDLocation)"documents and settings", (AccountName), (Filename))
                MessageBox.Show("Deleted")
            Catch
                MessageBox.Show("Unable to DELETE.", "Error")
            End Try
        End If
    End Sub

Any help on this would be greatly appreciated.

Many thanks

Bagleys

You should let the Win32 API look that up for you:

Dim dir As String = Environment.GetFolderPath(Environment.SpecialFolder.Personal)

Hi
Thank you so much i will give it ago, again many thanks

Bagleys

You should let the Win32 API look that up for you:

Dim dir As String = Environment.GetFolderPath(Environment.SpecialFolder.Personal)

Hi
That coding is exactly what I'm looking for but Ive tried using it and playing around with it but i cant get it to work with what i want it to do. To be honest i don't have a clue how to implement it into my code so that i can check a file exist and then be able to delete it. Please help.

Bagleys

This is what iv got but i don't know how to use it within this code to delete the file.

Dim FILE_NAME1 As String = "h:\Documents and Settings\bagleys\pwconns.log"
If CheckBox5.Checked = False Then

        ElseIf System.IO.File.Exists(FILE_NAME1) = True Then
            Try
                My.Computer.FileSystem.DeleteFile(FILE_NAME1)
                Label8.Text = "Deleted"
                Label8.ForeColor = Color.Blue
            Catch
                MessageBox.Show("Unable to DELETE.", "Error")
            End Try
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.