vbscript 写入与xdoc位于同一文件夹中的xdoc同名的文本文件

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了vbscript 写入与xdoc位于同一文件夹中的xdoc同名的文本文件相关的知识,希望对你有一定的参考价值。

Private Sub WriteFile(ByVal pxdoc As CASCADELib.CscXDocument, sContents As String)
   Dim sBaseFolderPath As String
   Dim sBaseFileName As String
   Dim sTxtFullPath As String
   Dim sOperatorUserID As String
   Dim FSO As Object
   Dim iFreeFile As Integer

   OutputDebugString "KfxKTM_WriteFile: Start"

   On Error Resume Next

   Set FSO = CreateObject("Scripting.FileSystemObject")

   sBaseFolderPath = FSO.GetParentFolderName(pxdoc.FileName)
   sBaseFileName = FSO.GetBaseName(pxdoc.FileName)
   sTxtFullPath = FSO.BuildPath(sBaseFolderPath, sBaseFileName) & ".txt"

   OutputDebugString "KfxKTM_Checking if txt file already exists..."
   If FSO.FileExists(sTxtFullPath) = True Then
      OutputDebugString "KfxKTM_txt File exists, Deleting..."
      FSO.DeleteFile(sTxtFullPath, True)
      OutputDebugString "KfxKTM_txt File deleted, Checking..."
      If FSO.FileExists(sTxtFullPath) = True Then
         OutputDebugString "KfxKTM_Could not delete"
         Exit Sub
      End If
      OutputDebugString "KfxKTM_Delete Confirmed"
   End If

   iFreeFile = FreeFile
   Open sTxtFullPath For Append As #iFreeFile
   OutputDebugString "KfxKTM_Opened File for append"
   OutputDebugString "KfxKTM_Writing text contents values"

   Print #iFreeFile, sContents

   Close #iFreeFile
   OutputDebugString "KfxKTM_Closed file"
   OutputDebugString "KfxKTM_WriteFile: Finish"

End Sub

以上是关于vbscript 写入与xdoc位于同一文件夹中的xdoc同名的文本文件的主要内容,如果未能解决你的问题,请参考以下文章

Bash - 从与脚本文件位于同一目录中的文件读取

如何可靠地打开与当前正在运行的脚本位于同一目录中的文件

我可以将文件写入linux目录,指定cfscript中的文件权限吗?

vbscript VBScript将可用磁盘空间写入文件

vbscript 在Excel VBA中读取和写入文件

如何在 Swift 中将文件写入位于 Apple Files App 中的文件夹