繁体   English   中英

在桌面上创建文件夹

[英]Create a folder on desktop

我想在桌面上创建一个文件夹,并且想创建一次。 但是,一旦安装了项目,则在调试程序时会出现以下错误:

从字符串到“ gfgffgfgfg”类型整数的转换无效

这是我的代码:

 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

我不知道将字符串传递给Desktop意味着什么,并且我期望其他形式的编译错误(尽管我不太了解VB编译器),但是也许您想要这样:

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

这应该返回要创建的文件夹的标准路径。

  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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM