Reputation: 961
protected void Page_Load(object sender, EventArgs e)
{
System.IO.File.WriteAllText(@"C:\CallInformation.txt", "Some data");
}
is CallInformation.txt on the Server? Or the client? If it's the server, other than specifying a computer name (@"\Workstation\c$\CallInformation.txt") how can I get it to save the file client side?
Upvotes: 1
Views: 360
Reputation: 3970
The file would be create on the server. To write it locally, you would need a client framework other than just the W3C DOM compliant browser, such as Silverlight and (maybe) Flash - and even then the user would be prompted to allow it to happen.
Here's a post that explains how it can be done:
Hope it helps.
Upvotes: 1
Reputation: 1456
If you are writing a web application, you should understand that the code runs on the server. So the file is saved on the server.
To send it to the client, you have to write the contents of the file to the response stream.
Upvotes: 3
Reputation: 709
It is built on the server. It would be a major security vulnerability if you could create a file on a client without them physically accepting it. You could always send the data to them as a stream and allow them to choose where to save it.
Upvotes: 5
Reputation: 15579
It's on the server. The code behind executes in the context of the web server.
To get a file to download, there are a few ways. One way is to do something along these lines:
Response.ContentType = "image/jpeg";
Response.AppendHeader("Content-Disposition","attachment; filename=SailBig.jpg");
Response.TransmitFile( Server.MapPath("~/images/sailbig.jpg") );
Response.End();
Upvotes: 4