0

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

2
Contributors
4
Replies
5
Views
7 Years
Discussion Span
Last Post by Bagleys
0

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

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

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

Bagleys

0

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

0

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

Edited by Bagleys: n/a

This article has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.