Jump to content

How to Get to A folder Without the full path In VB

snoopy6489
Go to solution Solved by bbtgp,

 

Would that work in visual basic.

this is the code for one of them

 
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        My.Computer.FileSystem.DeleteDirectory("C:\Users\Christian\Documents\Electronic Arts\The Sims 3\DCBackup",
        Microsoft.VisualBasic.FileIO.UIOption.AllDialogs,
        Microsoft.VisualBasic.FileIO.RecycleOption.DeletePermanently,
        Microsoft.VisualBasic.FileIO.UICancelOption.DoNothing)
    End Sub

 

 

Yes, My.Computer.FileSystem.SpecialDirectories.MyDocuments would also work

 

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        My.Computer.FileSystem.DeleteDirectory(My.Computer.FileSystem.SpecialDirectories.MyDocuments & "\Electronic Arts\The Sims 3\DCBackup",
        Microsoft.VisualBasic.FileIO.UIOption.AllDialogs,
        Microsoft.VisualBasic.FileIO.RecycleOption.DeletePermanently,
        Microsoft.VisualBasic.FileIO.UICancelOption.DoNothing)
    End Sub

Hello i'm making a program to delete the cache in sims 3 but how do i get to the folder without the full path so it will work on any computer? Thanks.

Here are the paths

"C:\Users\Christian\Documents\Electronic Arts\The Sims 3\simCompositorCache.package"

"C:\Users\Christian\Documents\Electronic Arts\The Sims 3\DCBackup"

"C:\Users\Christian\Documents\Electronic Arts\The Sims 3\compositorCache.package"

Link to comment
Share on other sites

Link to post
Share on other sites

What language are you developing in?

If it's just a simple script, most of the time %CD% should return you the current directory, in this case \The Sims 3\, which should be enough for the shell to interpolate the rest of the files.

Link to comment
Share on other sites

Link to post
Share on other sites

What language are you developing in?

If it's just a simple script, most of the time %CD% should return you the current directory, in this case \The Sims 3\, which should be enough for the shell to interpolate the rest of the files.

Visual Basic

Link to comment
Share on other sites

Link to post
Share on other sites

 

Take a look at https://msdn.microsoft.com/en-us/library/14tx8hby%28v=vs.110%29.aspx

        Dim MyDocuments = System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) & "\"        Console.WriteLine(MyDocuments & "Electronic Arts\The Sims 3\DCBackup")

Would that work in visual basic.

this is the code for one of them

 
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        My.Computer.FileSystem.DeleteDirectory("C:\Users\Christian\Documents\Electronic Arts\The Sims 3\DCBackup",
        Microsoft.VisualBasic.FileIO.UIOption.AllDialogs,
        Microsoft.VisualBasic.FileIO.RecycleOption.DeletePermanently,
        Microsoft.VisualBasic.FileIO.UICancelOption.DoNothing)
    End Sub
Link to comment
Share on other sites

Link to post
Share on other sites

 

Would that work in visual basic.

this is the code for one of them

 
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        My.Computer.FileSystem.DeleteDirectory("C:\Users\Christian\Documents\Electronic Arts\The Sims 3\DCBackup",
        Microsoft.VisualBasic.FileIO.UIOption.AllDialogs,
        Microsoft.VisualBasic.FileIO.RecycleOption.DeletePermanently,
        Microsoft.VisualBasic.FileIO.UICancelOption.DoNothing)
    End Sub

 

 

Yes, My.Computer.FileSystem.SpecialDirectories.MyDocuments would also work

 

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        My.Computer.FileSystem.DeleteDirectory(My.Computer.FileSystem.SpecialDirectories.MyDocuments & "\Electronic Arts\The Sims 3\DCBackup",
        Microsoft.VisualBasic.FileIO.UIOption.AllDialogs,
        Microsoft.VisualBasic.FileIO.RecycleOption.DeletePermanently,
        Microsoft.VisualBasic.FileIO.UICancelOption.DoNothing)
    End Sub
Link to comment
Share on other sites

Link to post
Share on other sites

 

Yes, My.Computer.FileSystem.SpecialDirectories.MyDocuments would also work

 

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        My.Computer.FileSystem.DeleteDirectory(My.Computer.FileSystem.SpecialDirectories.MyDocuments & "\Electronic Arts\The Sims 3\DCBackup",
        Microsoft.VisualBasic.FileIO.UIOption.AllDialogs,
        Microsoft.VisualBasic.FileIO.RecycleOption.DeletePermanently,
        Microsoft.VisualBasic.FileIO.UICancelOption.DoNothing)
    End Sub

 

Thank You So much!!!!!

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×