Maya Shb
Maya Shb

Reputation: 1

Create a folder on desktop

I want to create a folder on the desktop and I want to create it once. However, once my project is installed, when I debug my program I get this error:

Conversion from string to " gfgffgfgfg " type integer is not valid

Here is my code:

 Private Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click

    Try
        MkDir(My.Computer.FileSystem.SpecialDirectories.Desktop("gfgffgfgfg"))

    Catch ex As Exception
        MsgBox(ex.Message.ToString)
    End Try

Upvotes: 0

Views: 2326

Answers (2)

SELEXPED
SELEXPED

Reputation: 1

  Dim SELEXPED_DIR As String = My.Computer.FileSystem.SpecialDirectories.Desktop + "\SELEXPED"

    If Directory.Exists(SELEXPED_DIR) = False Then
        Try
            Directory.CreateDirectory(SELEXPED_DIR)

        Catch ex As Exception
            'Nothing to do
        End Try
    End If

Upvotes: 0

David
David

Reputation: 219117

I don't know what passing the string to Desktop is meant to do, and I'd expect other forms of compile errors (though I don't know the VB compiler very well), but maybe you want this:

Path.Combine(My.Computer.FileSystem.SpecialDirectories.Desktop, "gfgffgfgfg")

That should return the fully-qualified path for the folder being created.

Upvotes: 4

Related Questions