Reputation: 21935
I need to create a text file with mime type application/octet-stream.
With the following c# code:
string[] text = P_Data.M_Content.Split(',');
System.IO.File.WriteAllLines(@"c:\temp.txt", text);
This code generates a physical file on the server. However, the mime type is text/plain.
I need to modify this code in order to create a file with mime type application/octet-stream
Any ideas how this can be achieved?
EDIT This is the request from the GUI (ExtJS)
success: function(P_Response){
var res = Ext.util.JSON.decode(P_Response.responseText);
if(res == 'SUCCESS') window.location.href = 'myfile.txt';
else alert('the error message');
},
By using this code, a popup window is opened to download the file if I create a .doc instead of a .txt
Upvotes: 1
Views: 9722
Reputation: 45096
Only HTTP has a content type. You set it using this property.
HttpResponse.ContentType Property
Upvotes: 0
Reputation: 3130
If this is for a web application, you'll need to save your file as a binary file and then when the client requests it, you'll send the application/octet-stream
as part of the HTTP headers.
http://msdn.microsoft.com/en-us/library/system.io.binarywriter.aspx
Upvotes: 2