Hello All,
I am working on a task in that I want to import .bat file.
And want to show .bat file content in multi-line textbox. User can edit that
file content and user can again export that content as .bat file. For that I am using
ASP.NET MVC,JQUERY. I have succeeded to import content to textbox but am not able to
export that content as .bat file(not able to create save file dialog-box popup in asp.net mvc).
Please suggest me for this task.
I have two buttons(Import and Export) to submit same form so I have differentiate them using their name and value.
My code is as follow:
[HttpPost]
public ActionResult BatchFileSettings(string ImportExport, HttpPostedFileBase myfile, FormCollection formCollection)
{
if (ImportExport == "Import")
{
string result = "";
if (myfile != null)
{
BinaryReader b = new BinaryReader(myfile.InputStream);
byte[] binData = b.ReadBytes(Convert.ToInt32(myfile.InputStream.Length));
result = System.Text.Encoding.UTF8.GetString(binData);
}
return Json(result, JsonRequestBehavior.AllowGet);
}
else if (ImportExport == "Export")
{
string content = formCollection["BatchFile.Content"].ToString();
return File(Encoding.ASCII.GetBytes(content), "application/octetstream", "DFBatchFile.bat");
}
else
{
return Json("");
}
}
Thanks