如何使用vb.net读取和写入多个文件 [英] how to read and write multiple files using vb.net

查看:239
本文介绍了如何使用vb.net读取和写入多个文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在下面的代码中,我读取并写入了一个新文件,但是我对单个文件执行了此操作,如何对多个文件执行此操作




hi , here in the below coding i got the file readed and writed to a new file , but i done this for a single file , how can i do it for multiple files




Sub read1()
       Dim missing As Object = System.Reflection.Missing.Value
       Dim oFals As Object = False
       Dim oTru As Object = True

       Try
           objapp = New word.Application
           objdoc = New word.Document

           Dim obj As Object = ListBox1.SelectedItem
           If ListBox1.SelectedIndex < 0 Then
           Else
               If ListBox1.Items.Count > 0 Then
                   objdoc = objapp.Documents.Open(obj, missing, oTru, oTru)
                   objapp = New word.Application
                   objdoc = New word.Document
                   objdoc = objapp.Documents.Add(obj)
                   objdoc.SaveAs("d:\wrrd.doc")
                   objdoc.Activate()
                   objdoc.Close()
                   objapp.Quit()
                   objdoc = Nothing
                   objapp = Nothing
               End If
           End If

       Catch ex As Exception
           MsgBox("read error")
       End Try

   End Sub

推荐答案

创建参数为"filename"的函数...并在循环中调用相同的函数,根据需要生成文件名......:)
create a function with parameter of ''filename''... and call the same inside a loop, generate the file names as you desire...... :)


这篇关于如何使用vb.net读取和写入多个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆