tags:

views:

23

answers:

2

I need a VB script which will create text file named "listitem" in C:\Documents and Settings\All Users\Application Data\secon\smartapp up to C:\Documents and Settings\All Users\Application Data\ we can make it as 'CommonAppDataFolder'

Any one knows about this

+1  A: 

OK, let's see if I can remember how to do this...

Dim fso 'As Scripting.FileSystemObject
Dim stream 'As Scripting.TextStream

Set fso = CreateObject("Scripting.FileSystemObject")

'Check that the secon folder exists
If fso.FolderExists("C:\Documents and Settings\All Users\Application Data\secon") Then
Else
    fso.CreateFolder("C:\Documents and Settings\All Users\Application Data\secon")
End If

'Check that the smartapp folder exists
If fso.FolderExists("C:\Documents and Settings\All Users\Application Data\secon\smartapp") Then
Else
    fso.CreateFolder("C:\Documents and Settings\All Users\Application Data\secon\smartapp")
End If

'Create the file as ASCII text, overwrite it if it already exists
Set stream = fso.CreateTextFile("C:\Documents and Settings\All Users\Application Data\secon\smartapp\listitem.txt", true, false)

'Close it neatly
stream.Close

'Clean up
Set stream = Nothing
Set fso = Nothing
PhilPursglove
Thanks let me check that
peter
i need an optimized solution by using CommonAppData
peter
this wl work fine,but i need an optimized solution by using CommonAppData
peter
+1  A: 

Here're some tips for you:

Hope you can manage the rest yourself. :)

Helen
if you give the code ,that will be heplful and optimized
peter