Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FSO Please help

Status
Not open for further replies.

zishan619

Programmer
May 28, 2003
284
0
0
MX
I have the following:
dim fso
Dim newfolder
Dim strFolder
strFolder = "..\images\TAS\TAS_PayrollFiles\" & CCNum & ""
set fso=CreateObject("Scripting.FileSystemObject")
If Not filesys.FolderExists(strFolder) Then
Set newfolder = filesys.CreateFolder(strFolder)
Response.Write("A new folder has been created at: " & strFileNameRelative)
End If
' create a file system object
Dim strFileNameRelative
'set fso = server.CreateObject("scripting.FileSystemObject")
strFileNameRelative = "..\images\TAS\TAS_PayrollFiles\" & CCNum & "\PC_" & CCNum & "_" & FormatSysDate & ".xls"
strFileName = server.MapPath(strFileNameRelative)
Set act = fso.CreateTextFile (strFileName, True)

I wanted to know what is wrong with this statement?
I want basically to create a folder if it is created already then just go on and create the file inside the new folder. IF the folder is not created then create the folder and then the file.
Thanks
 
I think you might be having a problem resolving the relative path information. If you want to create a path relative to the script, you can use the following code to get the current path and append your relative path from there:
-----
Dim CurrentDir

CurrentDir = _
Left(WScript.ScriptFullName,InstrRev(WScript.ScriptFullName,"\"))
-----
Hope this helps.

- Glen

Know thy data.
 
Some notes:
- First at all, use the Option Explicit statement.
You will discover that you instantiate object fso and then use filesys, and that you use strFileNameRelative before the Dim.
- Allways use Server.MapPath before playing with fso.
- Set fso=Server.CreateObject("Scripting.FileSystemObject")
- You may have to consider using this:
curDir=fso.GetParentFolderName(Request.ServerVariables("PATH_INFO"))
Try reorganizing your code and let us know.

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top