Am using OpenXml to open, modify then save a docx document. The code (not shown) will open the document, modify and I can save it directly to a direct path. But cannot find how to make the user Save File AS dialog work? The type or namespace name 'SaveFileDialog' could not be found (are you missing a using directive or an assembly reference?)

    SaveFileDialog saveFileDialog1 = new SaveFileDialog();

    saveFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
    saveFileDialog1.FilterIndex = 2;
    saveFileDialog1.RestoreDirectory = true;

    if (saveFileDialog1.ShowDialog() == DialogResult.OK)
    {
     Response.Clear();
             Response.ContentType = "application/octet-stream";
             string fileNamewrite =(string) (Session["FileNameFromUser"]);
             Response.AddHeader("Content-Disposition",    String.Format("attachment; filename={0}",fileNameout));
             Response.BinaryWrite(mem.ToArray());
             Response.Flush();
             Response.End();

The SaveFileDialog is the kind of method I hoped to use but cannot find any such similar method.

Even tried to install a bootstrap dialog with nice graphics? http://getbootstrap.com/javascript/#modals this worked a few times, then after modifying to fit my code, button clicking did nothing. i went back to the original and pasted in, saved, still does nothing anymore.

The controller has modified the byte array, so at the Response.Clear(); to the end, this part runs and saves the file, but it has to be a user dialog save file as interface that returns the literal string path from the user?

Is there a similar kind of method as SaveFileDialog for MVC the controller can see?

Related posts

Recent Viewed