I managed to save it in a specific folder, but at the same time it is staying in the download folder and I do not know how to remove it so that it is only saved in the path I am passing through
using (SqlCommand cmd = new SqlCommand( "select * from prueba ")
using (SqlDataAdapter sda = new SqlDataAdapter())
{
cmd.Connection = con;
sda.SelectCommand = cmd;
using (DataTable dt = new DataTable())
{
sda.Fill(dt);
string txt = string.Empty;
foreach (DataRow row in dt.Rows)
{
foreach (DataColumn column in dt.Columns)
{
//Add the Data rows.
if (column.ColumnName.Equals("cantidadF"))
{
txt += row[column.ColumnName].ToString().Replace(",000", "").Replace(".000", "");
}
else if (column.ColumnName.Equals("cantidade"))
{
txt += row[column.ColumnName].ToString().Replace(",000", "").Replace(".000", "");
}
else if (column.ColumnName.Equals("Peso"))
{
txt += row[column.ColumnName].ToString().Replace(",000000", "").Replace(".000000", "");
}
else if (column.ColumnName.Equals("Volumen"))
{
txt += row[column.ColumnName].ToString().Replace(".", "").Replace(",", "").Remove(4, 3);
//.Remove(4,3)
}
else
{
txt += row[column.ColumnName].ToString();
}
}
//Add new line.
txt += "\r";
}
//Download the Text file.
Response.Clear();
Response.Buffer = true;
Response.AddHeader("content-disposition", "attachment;filename=" + "'" + TxtExportFactura.Text + ".txt" + "'" );
string filename = TxtExportFactura.Text + ".txt";
Response.Charset = "";
Response.ContentType = "application/text";
System.IO.File.AppendAllText(@"\xxserver\mult\mult\CROSS\" + filename, txt);
Response.Flush();
Response.End();
//...