Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi,

In my win application I use the following code to save the downloaded data into the necessary format

 

sw = File.CreateText(strPath & ".csv")

 

please not ethat .csv can be .xml instead

 

This works fine but what should I do in web (asp.net)?

I can not use the above line as it complains about the network path where the file should be installed.

 

If the best way is to get a dialog box to save as then how is it done please?

thanks

Farshad
  • Administrators
Posted

Do you want to save the data to the server or the client PC via their browser?

To prompt the browser to save use something similar to:

'Send data to client

Response.ContentType = "text/csv"    'Set the data type
Response.AppendHeader("Content-disposition:", "file; filename = Test.txt")     'Set the suggested filename
Dim s As IO.Stream = Response.OutputStream
'use s as a normal stream streamwriter etc.
Dim sw As New IO.StreamWriter(s)
sw.WriteLine("Data here")
sw.Flush()
sw.Close()

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...