以文本方式查看主题
- Foxtable(狐表) (http://foxtable.com/bbs/index.asp)
-- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2)
---- 一段批量导入的代码,但是路径总是提示不对 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=17884)
|
-- 作者:pb_1
-- 发布时间:2012/3/27 21:18:00
-- 一段批量导入的代码,但是路径总是提示不对
Dim ip As New Importer \'Dim DirPath=e.Form.Controls("DropBox1").value ip.SourcePath =e.Form.Controls("DropBox1").value
For Each File As String In FileSys.GetFiles(" & ip.SourcePath & ") ip.SourceTableName = "& file &" \'指定要导入的文件"订单.DBF" ip.NewTableName ="&file&" \'导入后的表名 ip.Format = "dbase" \'指定导入格式 If DataTables.Contains("&file&") \'如果存在统计表1 DataTables.Delete("&file&") End If ip.Import() Next
这是一个批量导入文件的代码,执行后总是提示这样的错误,求解答
此主题相关图片如下:未命名.jpg

|
-- 作者:shaof
-- 发布时间:2012/3/27 21:30:00
--
Dim ip As New Importer \'Dim DirPath=e.Form.Controls("DropBox1").value ip.SourcePath =e.Form.Controls("DropBox1").value
For Each File As String In FileSys.GetFiles(ip.SourcePath) ip.SourceTableName = file \'指定要导入的文件"订单.DBF" ip.NewTableName = file \'导入后的表名 ip.Format = "dbase" \'指定导入格式 If DataTables.Contains(file) \'如果存在统计表1 DataTables.Delete(file) End If ip.Import() Next
|
-- 作者:pb_1
-- 发布时间:2012/3/27 21:39:00
--
按楼上的作修改后却出现如下错误提示,求高人指点
此主题相关图片如下:未命名.jpg

|
-- 作者:shaof
-- 发布时间:2012/3/27 21:51:00
--
真正解决问题还得靠你自己,我只是修改了代码中明显错误之处。
现在还不明白DropBox中的值是什么?为何还要用遍历?
|
-- 作者:pb_1
-- 发布时间:2012/3/27 21:55:00
--
Dim dlg As New FolderBrowserDialog If dlg.ShowDialog = DialogResult.Ok Then e.sender.value=dlg.SelectedPath End If
就是一个获得目录路径的代码,我这不是自己解决不了才上来求助吗!
|
-- 作者:pb_1
-- 发布时间:2012/3/27 22:27:00
--
求解答
|
-- 作者:狐狸爸爸
-- 发布时间:2012/3/27 22:34:00
--
For Each File As String In FileSys.GetFiles(ip.SourcePath) Dim ip As New Importer ip.SourcePath =e.Form.Controls("DropBox1").value ip.SourceTableName = file \'指定要导入的文件"订单.DBF" ip.NewTableName = file \'导入后的表名 ip.Format = "dbase" \'指定导入格式 ip.Import() Next
|
-- 作者:pb_1
-- 发布时间:2012/3/27 22:57:00
--
狐狸爸爸!这个代码好像有点问题呢
|
-- 作者:程兴刚
-- 发布时间:2012/3/27 23:34:00
--
楼主不要激动,2给您的代码应该是对的,关键问题估计出在您的e.Form.Controls("DropBox1").value,这里的直绝对不能到文件名,而是最后一个文件的文件夹名称,最后一个字符必须是符号“\\”,如果您输入到文件名了,就对下面的循环造成影响了。
|
-- 作者:程兴刚
-- 发布时间:2012/3/27 23:36:00
--
您的代码出了问题,要改成这样才可以:
Dim dlg As New FolderBrowserDialog If dlg.ShowDialog = DialogResult.Ok Then e.sender.value=dlg.SelectedPath & "\\" End If
|