以文本方式查看主题

-  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=105124)

--  作者:zyl19810322
--  发布时间:2017/8/11 21:18:00
--  [求助]为啥删不掉文件?
\'\'\'
Dim t As Table = Tables("基本信息")
Dim fn As String = ""
For i As Integer = t.TopPosition To t.BottomPosition
    Dim tm As String  = ProjectPath & "Attachments\\回执.doc" \'指定模板文件
    Dim fl As String = ProjectPath & "Reports\\回执.doc" \'指定目标文件
    Dim wrt As New WordReport(t,tm,fl) \'定义一个WordReportTable: 要打印的表(Table)或表的名称
    Dim dr As DataRow
    Dim wfss As String = ""
    For Each dr In t.Rows(i).DataRow.GetChildRows("违法及处理情况")
        wfss &= dr("违法事实") & ","
        fn &= "回执(" & dr("案件编号") & ").doc"
    Next
    wrt.ReplaceOne("[全部违法事实]", wfss.trim(","))
    wrt.BuildOne(t.Rows(i))
    wrt.quit() \'显示报表
    If FileSys.FileExists(fn) Then
    FileSys.DeleteFile(fn)
    End If
    FileSys.RenameFile("Reports\\回执.doc",fn)
Next

自己写了一段代码,想为回执重命名,但是如果以前有同名的回执,我的思路是删掉,然后重命名。
但还是就奇怪在这里,居然没有删掉这个重复的文件,显示文件已存在,可是我通过代码删除了啊?
老师,这是咋回事呢?
[此贴子已经被作者于2017/8/11 21:43:45编辑过]

--  作者:有点蓝
--  发布时间:2017/8/11 21:30:00
--  
FileSys.DeleteFile(fn,2,2)


--  作者:zyl19810322
--  发布时间:2017/8/11 21:42:00
--  
还是一样啊

图片点击可在新窗口打开查看此主题相关图片如下:无标题.png
图片点击可在新窗口打开查看

--  作者:zyl19810322
--  发布时间:2017/8/11 21:52:00
--  
完全搞不定啊
--  作者:zyl19810322
--  发布时间:2017/8/11 22:06:00
--  回复:(有点蓝)FileSys.DeleteFile(fn,2,2)http://w...
给点意见吧
--  作者:有点蓝
--  发布时间:2017/8/11 22:08:00
--  
试试

Dim t As Table = Tables("基本信息")
For i As Integer = t.TopPosition To t.BottomPosition
    Dim tm As String  = ProjectPath & "Attachments\\回执.doc" \'指定模板文件
    Dim fl As String = ProjectPath & "Reports\\" \'指定目标文件
    Dim dr As DataRow
    Dim wfss As String = ""
    For Each dr In t.Rows(i).DataRow.GetChildRows("违法及处理情况")
        wfss &= dr("违法事实") & ","
        fl &= "回执(" & dr("案件编号") & ").doc"
    Next
    If FileSys.FileExists(fl) Then
        FileSys.DeleteFile(fl)
    End If
    Dim wrt As New WordReport(t,tm,fl) \'定义一个WordReportTable: 要打印的表(Table)或表的名称
    wrt.ReplaceOne("[全部违法事实]", wfss.trim(","))
    wrt.BuildOne(t.Rows(i))
    wrt.quit() \'显示报表
Next

--  作者:zyl19810322
--  发布时间:2017/8/11 22:15:00
--  
成了,为啥定义报表放后面就可以?放前面就不行?
--  作者:有点蓝
--  发布时间:2017/8/11 22:36:00
--  
文件占用,所以无法删除