Skip to content

File Dialog in web

Niclas

Asked Dec 18, 2007, 5:18 AM EST1 answer
Share
LinkedInX

I'm writing a file to the disk by using the StreamWriter:

StreamWriter sw = new StreamWriter("bigFile.txt");

sw.Write(myXmlNode.OuterXml);

I do this in a code behind (.aspx.cs) page. The file is close to 7Mb big. Instead of (or if that's not possible: in addition to) saving the file ot the disk, I want the user to get a file dialog so that he can save the file to his own disk instead of the server's disk. To clarify: since I'm using web and not for instance windows forms, I can't use the System.Windows.Forms classes (like FileDialog).

It seems like a pretty basic thing to do. Something that thousands of people have already done. So... Ideas?

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
    Use the following code to display file dialog:
    <input type="file" id="fileDialog" runat="server">
    0