Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old September 20th, 2007, 09:38 AM
Registered User
 
Join Date: Aug 2007
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default ASP write to txt file

Im getting a error when trying to write to a txt file.
Code:
Microsoft VBScript runtime  error '800a004c'

Path not found 

/BSTV/Video/VideoUpload.asp, line 295
Code:
dim fs,tfile
set fs=Server.CreateObject("Scripting.FileSystemObject")
set tfile=fs.CreateTextFile("E:\www\NMBSTV\Prototype\somefile.txt")


tfile.WriteLine(ful)
tfile.close
set tfile=nothing
set fs=nothing
Its so annoying i got it working on my test server and then moved it to another server and it gives this error i think it could be perrmisions but ive gave the folder read write permisions.

i also have the iis username password stuff setup.

Reply With Quote
  #2 (permalink)  
Old September 20th, 2007, 09:50 AM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Copy and paste this line into an Explorer window on your server that this error is being generated from:

E:\www\NMBSTV\Prototype\somefile.txt

What happens?


================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
Technical Editor for:
Professional Search Engine Optimization with ASP.NET

Professional IIS 7 and ASP.NET Integrated Programming

================================================== =========
Reply With Quote
  #3 (permalink)  
Old September 20th, 2007, 10:10 AM
Registered User
 
Join Date: Aug 2007
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I was using the wrong dir but im still getting an error




Code:
UPLOADING

Microsoft VBScript runtime error '800a0035'

File not found

/BSTV/Video/check.asp, line 102
this however opens what is in the text file which is just a filename which is ment to be in thier.

e:\web\www\NMBSTV\Prototype\somefile.txt
Reply With Quote
  #4 (permalink)  
Old September 20th, 2007, 10:16 AM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

The purpose of my previous post was just to validate that the path in your code was correct on the server since the interpeter message said otherwise.

The error you posted above is from a different page then your original post. What is line 102?

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
Technical Editor for:
Professional Search Engine Optimization with ASP.NET

Professional IIS 7 and ASP.NET Integrated Programming

================================================== =========
Reply With Quote
  #5 (permalink)  
Old September 25th, 2007, 05:04 AM
Authorized User
 
Join Date: Dec 2006
Location: Mumbai, Maharastra, India.
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I think this error is coming b'coz u r using real path of file.

Try this--

(1) In which virtual Directory (Folder) u r using for your website, Create a Folder named - Upload.

(2) At the place you are giving code to create text file use this.

set tfile=fs.CreateTextFile(server.MapPath("upload")+" \somefile.txt")

It may be helpful for you.


Reply With Quote
  #6 (permalink)  
Old June 14th, 2010, 10:20 PM
Registered User
 
Join Date: Jun 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Classic ASP writing file error

I am getting an "Object Required" error when calling this function... It's driving me crazy because from all I can find on line this code looks good. I have another function that can read the contents of the file just fine but when I try and write to it (over it) I get the error. Any help would be great.

Code:
    Function WriteDataToFile(strFilePath, txt)
        on error resume next
      
        dim objFSO, objFile
        strFilePath = Server.MapPath(strFilePath)
      
        Set objFSO = Server.CreateObject("Scripting.FileSystemObject")

        ' Getting error on this line....
        Set objFile=objFSO.CreateTextFile(strFilePath)

        objFile.WriteLine(txt)
        objFile.Close
        Set objFile = nothing
        Set objFSO = nothing
      
        if err then response.Write(err.Description)
    End Function
Reply With Quote
  #7 (permalink)  
Old June 15th, 2010, 07:36 PM
Friend of Wrox
 
Join Date: Jun 2008
Location: Snohomish, WA, USA
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

I don't understand how you can get an error when you use (yuck!!) ON ERROR RESUME NEXT. Unless you mean you see the error down at that last line.

Anyway...if the file already exists, then CreateTextFile will fail.

Unless you add another argument to it:
Code:
Set objFile=objFSO.CreateTextFile(strFilePath, True)
That TRUE argument says "overwrite if exists".
Reply With Quote
  #8 (permalink)  
Old June 15th, 2010, 10:38 PM
Registered User
 
Join Date: Jun 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yep, I added the on error so I could see what was going...

As it turns out - I figured there had to be an issue with the server's write permissions and that was the problem. Anyway, all works with the code after the ISP changed the permissions.

Thanks for looking at it and the reply.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't get Log to write the Log.txt file jnbutler BOOK: Professional XNA Game Programming: For Xbox 360 and Windows ISBN: 978-0-470-12677-6 3 July 31st, 2007 04:04 AM
Problem : Write to txt file al-hijjawi ASP.NET 1.0 and 1.1 Basics 0 April 10th, 2006 04:32 AM
write values to txt file in server eresina Javascript 7 July 19th, 2005 08:23 AM
write values to txt file in server eresina Javascript How-To 1 July 19th, 2005 05:11 AM



All times are GMT -4. The time now is 01:15 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.