Hi all,
I am trying to return just the filename from PostedFile.Filename when I
upload a file in ASP.NET (C#)
like this:
string s = UploadField.PostedFile.FileName
This returns something like "c:\Inetpub\wwwroot\myFolder\test.gif" but I
just want to get the filename
only, ie, "test.gif".
However, when I try and split it up to get the string after the last \
character, it throws errors
such as "unrecognised escape sequence" or "newline in constant".
I know I'm missing something really obvious, but I've drawn a blank so far.
Here's the code I was using:
string s = "E:\wwwroot\personal\phil\dotNet\example.gif";
test[] = s.Split("\");
for(int i = 0; i<test.Length; i++) {
Response.Write(test(i));
}
many thanks in advance
Phil
Phil Steel
TEQUILA\ Digital
82 Charing Cross Road
LONDON WC2H 0QB
020 7557 6228