Hi
Thank u but I hv already done that:-
protected void Button1_Click(object sender, EventArgs e)
{
string filen1 = "";
if (FileUpload1.HasFile)
{
try
{
filen1 = FileUpload1.FileName;
FileUpload1.SaveAs(Server.MapPath("Files/" + filen1));
}
catch (Exception err)
{
lblMsg.Visible = true;
lblMsg.Text = err.Message;
}
}
else
{
lblMsg.Visible = true;
lblMsg.Text = "Please upload the file!!";
}
long g = CountLines(filen1);
//long g = CountLines("D:/test.txt");
Response.Write(g);
}
static long CountLines(string f)
{
long count = 0;
using (StreamReader r = new StreamReader(f))
{
string line;
while ((line = r.ReadLine()) != null)
{
count++;
}
}
return count;
}
My Problem is the path-when I have uploaded the file, it goes to files folder in my project, but when same path is passed to countlines function it takes something as :-
c:\programfiles\.....\files\myfile.txt
it cant find it,Its obvious my file is in c:\inetpub\wwwroot\myproject\files\myfile.txt
I dont know how to rectify the path problem?