Rss & SiteMap

Foxtable(狐表) http://www.foxtable.com

新一代数据库软件,完美融合Access、Foxpro、Excel、vb.net之优势,人人都能掌握的快速软件开发工具!
共1 条记录, 每页显示 10 条, 页签: [1]
[浏览完整版]

标题:图片上传完成后不显示图片显示红色叉号

1楼
deliangzhaoe 发表于:2025/3/15 19:22:00
做了一个文件管理器模式窗口,窗口中加了图片查看器,图片上传能成功,但是上传后不显示图片内容,显示叉号,双击打开时,显示“此文件不存在”,打开文件存储位置,文件是正常存在的,这是怎么回事?代码应该怎么修改一下。谢谢!
上传按钮的代码如下:
Dim 当前目录 As String = e.Form.Controls("当前目录").text
Dim 刷新 As WinForm.Button = e.Form.Controls("刷新")
Dim curtable As Table = vars("tabc")
Dim curColName As String = curtable.Cols(curtable.ColSel).Name
Dim curCol As DataCol = curtable.DataTable.datacols(curColName)
Dim dr As DataRow = curtable.Current.DataRow
Dim openFilter As String = ""
Dim tpBl As Boolean = False

' 判断是否是图片列
If curCol.ExtendType = ExtendTypeEnum.Images Then
    openFilter = "文件|*.jpeg;*.bmp;*.jpg;*.png;*.gif"
    tpBl = True
Else
    openFilter = "所有文件|*.*"
End If

Dim dlg As New OpenFileDialog ' 定义一个新的OpenFileDialog
dlg.Filter = openFilter ' 设置筛选器
dlg.MultiSelect = True

If dlg.ShowDialog = DialogResult.OK Then ' 如果用户单击了确定按钮
    Dim upOk As New List(Of String)
    Dim upNok As New List(Of String)
    Dim result As New List(Of String)
    
    For Each fl As String In dlg.FileNames
        Dim fl2 As String = fl
        If tpBl Then
            ' 压缩图片
            fl2 = Functions.Execute("压缩图片", fl, 350)
            If fl2 Is Nothing Then Continue For
        End If
        
        Dim flname As String = FileSys.GetName(fl2)
        Dim 目标路径 As String = 当前目录 & "\" & flname
        
        ' 将文件复制到本地目录
        Try
            FileSys.CopyFile(fl2, 目标路径, True)
            upOk.Add("上传成功: " & flname)
            result.Add(目标路径)
        Catch ex As Exception
            upNok.Add("上传失败: " & flname)
            Dim tishi As String = String.Join(vbCrLf, upNok.ToArray)
            MessageBox.Show(tishi) ' 新增的,上传失败必须提示
        End Try
        
        ' 删除压缩后的临时文件
        If tpBl Then
            FileSys.DeleteFile(fl2)
        End If
    Next
    
    ' 把成功的添加到记录里面
    For Each s As String In dr.Lines(curColName)
        If result.Contains(s) Then Continue For
        result.Add(s)
    Next
    
    dr.Lines(curColName) = result
    刷新.PerformClick()
End If

文件管理器窗口如图:

图片点击可在新窗口打开查看此主题相关图片如下:微信截图_20250315191944.png
图片点击可在新窗口打开查看
双击打开文件时报错:

图片点击可在新窗口打开查看此主题相关图片如下:微信截图_20250315191957.png
图片点击可在新窗口打开查看


共1 条记录, 每页显示 10 条, 页签: [1]

Copyright © 2000 - 2018 foxtable.com Tel: 4000-810-820 粤ICP备11091905号

Powered By Dvbbs Version 8.3.0
Processed in .02930 s, 2 queries.