Wednesday, October 29, 2014

Get httpPostedFileBase FileName only code or extract last portion of file director path

var httpPostedFileBase = Request.Files.Get("DocumentFileName");
               var myFileName = string.Empty;
               if (httpPostedFileBase != null)
               {
                   int position = httpPostedFileBase.FileName.LastIndexOf('\\');
                   myFileName = httpPostedFileBase.FileName.Substring(position + 1);
               }

No comments: