Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Save csv file type as txt
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Save csv file type as txt

 Post Reply Post Reply
Author
itindy View Drop Down
Newbie
Newbie
Avatar

Joined: 23 September 2003
Location: United States
Status: Offline
Points: 2
Post Options Post Options   Thanks (0) Thanks(0)   Quote itindy Quote  Post ReplyReply Direct Link To This Post Topic: Save csv file type as txt
    Posted: 06 October 2003 at 11:40am
I am trying to save a csv file as either a csv or txt on the user's computer.  When I click to save the file, then select the drop box to save as a text file, there is no option.  I can save as a csv file or I can select "All Files" and add .txt to the file name.  Since most users will not know to select "All Files" and add the txt extension, I need a way to add the text file option to the drop box.  Is there an easy way to do this in ASP or any other method?
Back to Top
MorningZ View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 May 2002
Location: United States
Status: Offline
Points: 1793
Post Options Post Options   Thanks (0) Thanks(0)   Quote MorningZ Quote  Post ReplyReply Direct Link To This Post Posted: 06 October 2003 at 12:56pm
you could use the FileSystemObject to "rename" (technically there is no rename method, but you could use the "move" method to accomplish the same) the file to the .txt extension
Contribute to the working anarchy we fondly call the Internet
Back to Top
fernan82 View Drop Down
Mod Builder Group
Mod Builder Group
Avatar

Joined: 17 November 2002
Location: United States
Status: Offline
Points: 362
Post Options Post Options   Thanks (0) Thanks(0)   Quote fernan82 Quote  Post ReplyReply Direct Link To This Post Posted: 06 October 2003 at 7:09pm

You can also use the Stream Object to make the user download the file with a different name..... here's a sample function that will download a file called File.csv located on D:\ on your server as File.txt. You can even change the whole name:

Response.Buffer = True
Response.Clear

Call ForceDownload("D:\File.csv", "File.txt")

Function ForceDownload(strPath, strfilespec)      

         Dim oStream

         Set oStream = server.createobject("ADODB.Stream")

         oStream.Open
         oStream.Type = 1 ' Binary 
         oStream.LoadFromFile strPath        
          
         Respon se.ContentType="application/unknown"
         Respon se.AddHeader "Content-Disposition","attachment; filename=" & chr(34) & strfilespec & chr(34) 
         Respon se.BinaryWrite oStream.Read

         Response.Flush
         oStream.Close
         Set oStream = Nothing 
End Function

 

FeRnAN
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.