
<asp:FileUpload ID="FileUpload1" runat="server" />
<asp:Button ID="Btn1" Text="click" runat="server" onclick="Btn1_Click" />
protected void Btn1_Click(object sender, EventArgs e)
{
StreamReader Sr = new StreamReader(FileUpload1.PostedFile.FileName);
string Line = string.Empty; ;
int CountLine = 0;
int countfile = 1;
string[] lines = new string[100];
while ((Line = Sr.ReadLine()) != null)
{
for (CountLine = 0; CountLine < 5; CountLine++)
{
lines[CountLine] = Line;
Line = Sr.ReadLine();
}
string newpath = "C:\\Users\\pavan\\Desktop\\Hi\\" + countfile + ".txt";
System.IO.File.WriteAllLines(@newpath, lines);
countfile++;
}
Sr.Close();
}
Mark answer if this helps you
Thanks
Pavan Kumar
Mark Answer if this fits the need
Anishabathija, if this helps please login to Mark As Answer. | Alert Moderator