图像转换使用每个

时间:2015-05-19 16:11:27

标签: vb.net image converter

我正在尝试使用VB.Net将目录中的所有.png文件转换为.ico

   Dim DI As New System.IO.DirectoryInfo(PNGFolderConverter.Text)
        Dim Files As System.IO.FileInfo() = DI.GetFiles("*.png")
        For Each Fl As System.IO.FileInfo In Files
            Dim i As Integer
            i += 1

            Dim SourceImg As Image
            SourceImg = System.Drawing.Image.FromFile(Files)
            SourceImg.Save(PNGSaveDir.Text & "\" & i.ToString & ".ico", ImageFormat.Icon)

        Next

但我无法让它工作......我要么出错,要么只是语法错误。

有人可以帮助我吗?

2 个答案:

答案 0 :(得分:0)

您需要使用Name property并使用循环变量Fl而不是Files

Dim DI As New System.IO.DirectoryInfo(PNGFolderConverter.Text)
Dim Files As System.IO.FileInfo() = DI.GetFiles("*.png")
For Each Fl As System.IO.FileInfo In Files
    Dim i As Integer
    i += 1

    Dim SourceImg As Image
    SourceImg = System.Drawing.Image.FromFile(Fl.Name)
    SourceImg.Save(PNGSaveDir.Text & "\" & i.ToString & ".ico", ImageFormat.Icon)

Next

答案 1 :(得分:0)

/Library/Ruby/Gems/2.0.0/gems/

这有效。

除了" Fl.Name"我还必须添加保存目录和" \"。