以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  [求助]代码为何不起作用?  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=78827)

--  作者:wyz20130512
--  发布时间:2015/12/17 20:41:00
--  [求助]代码为何不起作用?
Dim dlg As New OpenFileDialog
dlg.Filter = "Word文件|*.doc"
dlg.MultiSelect = True
Dim files() As String = dlg.FileNames
If dlg.ShowDialog = DialogResult.OK Then
    Dim fb_dlg As New FolderBrowserDialog
    If fb_dlg.ShowDialog = DialogResult.OK Then
        msgbox(1)
        For Each file As String In files
            msgbox(2)
            FileSys.CopyFile(file,fb_dlg.SelectedPath & "\\" & FileSys.GetName(file),True)
        Next
    End If
End If

以上代码为何不起作用?只运行至msgbox(1)就停止了?

--  作者:大红袍
--  发布时间:2015/12/17 20:43:00
--  
Dim files() As String = dlg.FileNames
If dlg.ShowDialog = DialogResult.OK Then

 

改成

 

If dlg.ShowDialog = DialogResult.OK Then
    Dim files() As String = dlg.FileNames

--  作者:wyz20130512
--  发布时间:2015/12/17 20:46:00
--  回复:(大红袍)Dim files() As String = dlg.FileNa...
哦!明白了,此时dlg.FileNames 还没生成,是不是?

真的很感谢“大红袍”老师的指点,及时 准确!
[此贴子已经被作者于2015/12/17 20:49:19编辑过]