Forum Discussion

SLibernard's avatar
SLibernard
Occasional Contributor
9 years ago

Using createTextFile() to create a text file, but weird thing happens

I want to create a text file, and use the method createTextFile(), code as following:

 

Dim oFSO,OpenFile

 

CreateFolder(sFilePath)

 

set oFSO = CreateObject ("Scripting.FileSystemObject")

set OpenFile = oFSO.CreateTextFile(sFilePath,true)

OpenFile.WriteLine sColumnHeadText

OpenFile.Close

 

and what confuse me is that a filefolder named "123.txt" is created in the specific path but not a text file. I have already give the permissions, and I can manually create a 123.txt there. It's strange.

 

2 Replies

  • NisHera's avatar
    NisHera
    Valued Contributor

    Use

     

     

    set OpenFile = oFSO.CreateTextFile(sFilePath+"\123.txt",true)

    sFilePath should not include "\123.txt"