Change File Name

  • Thread starter Thread starter Eliyahu Goldin
  • Start date Start date
E

Eliyahu Goldin

Did you try changing file name just in the AddHeader line?

Response.AddHeader("Content-Disposition", "attachment; filename=test.txt");

Eliyahu
 
I have code to download a file from a webserver to a local machine through
the browser using code
dim file as System.IO.FileInfo = new System.IO.FileInfo("c:\_6_test.txt")
Response.Clear();
Response.AddHeader("Content-Disposition", "attachment; filename=" +
file.Name)
Response.AddHeader("Content-Length", file.Length.ToString())
Response.ContentType = "application/octet-stream"
Response.WriteFile(file.FullName)
Response.End()

Works OK. I need to remove the _6_ in front of the test.txt. The _6_ is an
internal number I use and the file(filename) is stored with this 'header'
on the server disk. I just need change the filename in the SAVEAS dialog box
that pops up when the user clicks a button to download this file to say just
text.txt. I cant seem to find the right combo. Changing the code above to
just text.txt gives me a file not found, of course. I've seen this done
before (changing the filename during download) but don't know how it is
done.
Thanks
Buc
 
That worked.. Thanks

Eliyahu Goldin said:
Did you try changing file name just in the AddHeader line?

Response.AddHeader("Content-Disposition", "attachment;
filename=test.txt");

Eliyahu
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top