Hi all,
I use asp.net with c#. I upload a file and save in a directory. I want to reopen the file so i check for file exists and then open it. But though the file exists, the file.exists(ful lpath) returns false . can anyone help me ? My code is here...
[CODE=C#]
string paths = this.MapPath(". ./TerminateDoc/Excel/" + fileName.Trim() );
/* paths = C:\\Inetpub\\ww wroot\\EIS\\Emp loyee.Web\\Term inateDoc\\Excel \\fi0002264Proo fDoc20080708101 851.txt */
if (File.Exists(pa ths)) // returns false ????
{
FileInfo fi = new FileInfo(paths) ;
Response.Clear( );
Response.ClearH eaders();
Response.Buffer = false;
Response.Append Header("Content-Disposition", "attachment;fil ename=" + System.Web.Http Utility.UrlEnco de(System.Text. Encoding.UTF8.G etBytes(fileNam e)));// + System.Web.Http Utility.UrlEnco de(System.Text. Encoding.UTF8.G etBytes(Path.Ge tFileName(paths ))));
Response.Append Header("Content-Length", fi.Length.ToStr ing());
Response.Conten tType = "applicatio n/octet-stream";
Response.WriteF ile(paths);
Response.Flush( );
Response.End();
}
else
{
this.RegisterSt artupScript("er ror", "<script>alert( 'The file is not uploaded or it has been deleted!');</script>");
}[/CODE]
Thank You
I use asp.net with c#. I upload a file and save in a directory. I want to reopen the file so i check for file exists and then open it. But though the file exists, the file.exists(ful lpath) returns false . can anyone help me ? My code is here...
[CODE=C#]
string paths = this.MapPath(". ./TerminateDoc/Excel/" + fileName.Trim() );
/* paths = C:\\Inetpub\\ww wroot\\EIS\\Emp loyee.Web\\Term inateDoc\\Excel \\fi0002264Proo fDoc20080708101 851.txt */
if (File.Exists(pa ths)) // returns false ????
{
FileInfo fi = new FileInfo(paths) ;
Response.Clear( );
Response.ClearH eaders();
Response.Buffer = false;
Response.Append Header("Content-Disposition", "attachment;fil ename=" + System.Web.Http Utility.UrlEnco de(System.Text. Encoding.UTF8.G etBytes(fileNam e)));// + System.Web.Http Utility.UrlEnco de(System.Text. Encoding.UTF8.G etBytes(Path.Ge tFileName(paths ))));
Response.Append Header("Content-Length", fi.Length.ToStr ing());
Response.Conten tType = "applicatio n/octet-stream";
Response.WriteF ile(paths);
Response.Flush( );
Response.End();
}
else
{
this.RegisterSt artupScript("er ror", "<script>alert( 'The file is not uploaded or it has been deleted!');</script>");
}[/CODE]
Thank You
Comment