ASP/Perl website FSO method fails to locate file since migrating from Win2k server to shared hosting

Posted on 2014-07-10
Last Modified: 2014-07-11
Since migrating from windows 2000 to shared windows hosting environment failed website functioning. Is it permissions or the code that needs to change. Unfortunately if it is permissions I have no control because this is a shared hosting environment.  If the code is the problem what can I replace it with?  

The code that fails without error - i have been able to determine the  fso.FileExists( SaleRecord ) = False but can't determine why.  Code follows:

'open the text file
	' Instantiate a FileSystem Object
      Set fso = CreateObject( "Scripting.FileSystemObject" )

      ' SaleRecord path must be modified to reflect the file 
      ' structure of the server
      SaleRecord = "C:\inetpub\wwwroot\DWeb\SaleItems\" & _

      ' Check if the file exists, if not create it
      If fso.FileExists( SaleRecord ) = True Then

      ' Open the SaleRecord and create the entry 
        Set tso = fso.OpenTextFile( SaleRecord, 1, false )
with Response
			line = tso.readline            'strip header line
			while not tso.AtEndOfStream
				line = trim(tso.readLine)
				line = right(line,len(line)-1)
				for i = 0 to 6
					pos = Instr(line,"@")
					items(i) = left(line,pos-1)
					line = right(line, len(line) -(pos+2))
				 items(7) = left(line,len(line)-1)
				.Write tr 
				for i = 0 to 7
					.Write td & items(i) & tdend
				.Write trend
		 end with
        Call tso.Close()
        set tso = nothing  
	  end if   'file exist   
	  set fso = nothing

Open in new window

Question by:rivarama
    LVL 82

    Expert Comment

    by:Dave Baldwin
    Shared hosting is not usually at "C:\inetpub\wwwroot\".  You have to find the actual path your shared hosting uses to get to your site.
    LVL 52

    Expert Comment

    by:Scott Fell, EE MVE
    >   ' Check if the file exists, if not create it

    You are also going to need to change the permissions on the folder where you are accessing this in order to create or delete files.  The iuser needs write permissions.

    If you have issues with your hosting, try another.   I used to use newtek.   Their legacy plans have full support for classic asp and you can easily change permissions to folders.
    LVL 32

    Accepted Solution

    try changing

    SaleRecord = "C:\inetpub\wwwroot\DWeb\SaleItems\sales.txt"


    SaleRecord = Server.MapPath("/SaleItems/sales.txt")

    this assumes there's a folder off your root called SalesItems. The Server.MapPath function will translate the virtual path to the physical path, so assuming the file exists, that should work.

    Author Comment

    RE: Path:  I posted the original code for simplicity.  

    Monty, The command worked perfectly!  Thanks so much!

    Author Closing Comment

    Learning ASP on the fly!  Thanks for a simple solution. :)

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
    I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
    Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now