Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- string FilePath = HttpContext.Current.Server.MapPath("~/FILENAME.txt");
- string FileContent = "";
- FileContent += "Text Here" + Environment.NewLine;
- File.WriteAllText(FilePath, FileContent);
- byte[] fileBytes = System.IO.File.ReadAllBytes(FilePath);
- string FilePath = HttpContext.Current.Server.MapPath("~/FILENAME.txt");
- string FileContent = "";
- FileContent += "Text Here" + Environment.NewLine;
- File.WriteAllText(FilePath, FileContent);
- var file = HttpContext.Current.Server.MapPath("~/FILENAME.txt");
- HttpContext.Current.Response.AppendHeader("content-disposition", "attachment; filename=NewFile.txt");
- HttpContext.Current.Response.ContentType = "application/octet-stream";
- HttpContext.Current.Response.TransmitFile(file);
- HttpContext.Current.Response.End();
- $.ajax({
- url: "/api/WebService/spPOImportGenImportPOTxt/" + $("#ID").val(),
- type: "POST",
- contentType: "application/octet-stream; charset=utf-8",
- error: function(request, status, error) {
- alert("Something went wrong: " + error);
- $.unblockUI();
- },
- success: function(data) {
- alert("Data has been successfully saved.");
- console.log(data);
- $.unblockUI();
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement