mimic
mimic

Reputation: 5224

How to opent text file for editing, ASP.NET?

The page has link to the text file placed somewhere in the network. If I click the link the file will be opened in the browser without the opportunity to edit it. How to do that user can click and open it in his/her favorite text editor? Thanks

Upvotes: 0

Views: 1132

Answers (2)

azamsharp
azamsharp

Reputation: 20086

If all you are trying to do is to edit the contents of the TEXT file then why not display the contents in a TextBox and let users update the contents and then save it.

Upvotes: 1

hunter
hunter

Reputation: 63542

they'll need to download it as an attachment

string fileName = "text.txt";
string filePath = Server.MapPath("~/" + fileName);
Response.Clear();

Response.AppendHeader("content-disposition", "attachment; filename=" + fileName);
Response.ContentType = "application/octet-stream";
Response.WriteFile(filePath);
Response.Flush();
Response.End();

Upvotes: 1

Related Questions