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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FileSystemObject

Status
Not open for further replies.

Zipster

Programmer
Nov 13, 2000
107
GB
Hi,

I have a rather complicated page that gets a web page from our network and copies it, changes information within it and then renames it.

The problem is that sometimes it seems to work and other times it doesn't.

Here's the code:

<%@LANGUAGE = &quot;VBSCRIPT&quot; %>
<%Option Explicit%>
<!-- #include file = &quot;../aspincludes/functions/checkuser.asp&quot; //-->
<!-- #include file = &quot;../aspincludes/Uploader/upload.asp&quot; //-->
<%
'Function to allow different access level for each page
Usercheck(2)

' Create the FileUploader
' This starts the upload process
Dim Uploader, File, myUser, subtype, objFSO, myFile

Dim myDate
myDate = Date
myDate = Day(myDate) & &quot;-&quot; & Month(myDate) & &quot;-&quot; & Year(myDate)

Set Uploader = New FileUploader
Uploader.Upload()

subtype = Uploader.Form(&quot;subtype&quot;)

myUser = Uploader.Form(&quot;Customer&quot;)
myUser = myDate + myUser + &quot;.htm&quot;

If myUser = &quot;&quot; Then
Response.Redirect(&quot;add_&quot; & subtype & &quot;.asp?myError=Please%20select%20a%20user!&quot;)
End If

If Uploader.Files.Count = 0 Then
Response.Redirect(&quot;add_&quot; & subtype & &quot;.asp?myError=File%20upload%20error!&quot;)
Else
For Each File In Uploader.Files.Items
' Save the file
File.SaveToDisk &quot;c:\inetpub\ & subtype & &quot;\&quot;
myFile = File.FileName
Next
End If

'''' Move/rename file bit

Set objFSO = CreateObject(&quot;Scripting.FileSystemObject&quot;)

Dim FromFile, ToFile, f, f2

' subtype is either quote,booking,itinerary depending on which page from.
FromFile = &quot;c:\inetpub\ & subtype & &quot;\&quot; & myFile
ToFile = &quot;c:\inetpub\ & subtype & &quot;\&quot; & myUser

If objFSO.FileExists(ToFile) Then
objFSO.DeleteFile ToFile
Else
objFSO.CopyFile FromFile, ToFile
objFSO.DeleteFile FromFile
End If

Do While 0 < 1
If objFSO.FileExists(ToFile) Then Exit Do
Loop
Set f = objFSO.OpenTextFile(ToFile, 1, false)

Dim fileContent
fileContent = f.ReadAll
fileContent = Replace(fileContent, &quot;\\coronation04\qtimages\&quot;, &quot;f.Close

Set f2 = objFSO.OpenTextFile(ToFile, 2, false)

f2.Write fileContent
f2.Close

Set objFSO = Nothing
Set f = Nothing
Set f2 = Nothing
'Now open the file and change network path of images to path a internet user can see

Response.Redirect &quot;/cms/maincms.asp&quot;
%>

I hope you'll be able to help me cheers.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top