Rss & SiteMap

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

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

标题:try 如何用

1楼
shixia 发表于:2010/12/27 13:23:00

Dim nl As String
Dim fl As String

If dlg.ShowDialog = DialogResult.OK Then
        For Each fl In dlg.FileNames
            nl = ph & FileSys.GetName(fl)
            FileSys.MoveFile(fl,nl,False)
            lst.Items.Add(nl)
        Next
Else '单击取消,则不执行后面代码
        Return

End If

 

这段代码想实现的功能是“移动”文件。但是如果要移动的文件正被打开使用,那么就会弹出非常不友好的报错界面。用Try 不好用。请指教。


2楼
狐狸爸爸 发表于:2010/12/27 14:35:00

Dim nl As String
Dim fl As String

If dlg.ShowDialog = DialogResult.OK Then
        For Each fl In dlg.FileNames
            nl = ph & FileSys.GetName(fl)

            Try

                 FileSys.MoveFile(fl,nl,False)
                 lst.Items.Add(nl)
            Catch ex As Exception
                 MessageBox.Show("文件正在使用","提示",MessageBoxButtons.OK)
            End Try

        Next
Else '单击取消,则不执行后面代码
        Return

End If

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

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

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