public FileStreamResult GenerateDailyBalanceFile(SqlConnection sqlconnection, DataTable dt)
{
FileStream fs = null;
BinaryWriter writer = null;
fs = new FileStream(physicalPath, FileMode.OpenOrCreate);
writer = new BinaryWriter(fs);
writer.Write(encode.GetBytes(recordtypefooter + numberofpoolbatch.ToString().Trim().PadLeft(4) + totrowscount.ToString().Trim().PadLeft(6)
+ ds.Tables[0].Rows[0]["totalbatsumfullfile"].ToString().Trim().PadLeft(15) + ds.Tables[0].Rows[0]["totalbatintsumfullfile"].ToString().Trim().PadLeft(15)
+ ds.Tables[0].Rows[0]["battotamt"].ToString().Trim().PadLeft(15)));
//How to Create and Open the text File
writer.Close();
fs.Close();
return new FileStreamResult(new FileStream(physicalPath,FileMode.Open), "xml/txt");
}
Best Regards,
Jean
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
Member
28 Points
59 Posts
Create and open textfile using FileStreamResult C#
Sep 15, 2017 04:54 AM|kanmai|LINK
Hi,
How to create a text file from datatable using FileStreamResult.Any help appreciated
Contributor
6420 Points
2527 Posts
Re: Create and open textfile using FileStreamResult C#
Sep 18, 2017 07:58 AM|Jean Sun|LINK
Hi Kanmai,
Please try add the following code here:
Best Regards,
Jean
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.