asp.net - How to get the Filename in code behind on selecting a file, before uploading it to the server using aspx and CS? -
i want retrieve file name , perform validation on filename. before uploading have filename of file selected uploading.
actually wanted filename , retrieve fields database based on file chosen , , send data retrieved database on client side in textfield. before on click of upload need call method in code behind validate these things. tried using ajaxcontroltoolkit, not working.
use getfilename() method. below example msdn link.
string filename = @"c:\mydir\myfile.ext"; string path = @"c:\mydir\"; string result; result = path.getfilename(filename); console.writeline("getfilename('{0}') returns '{1}'", filename, result); result = path.getfilename(path); console.writeline("getfilename('{0}') returns '{1}'", path, result); // code produces output similar following: // // getfilename('c:\mydir\myfile.ext') returns 'myfile.ext' // getfilename('c:\mydir\') returns ''
Comments
Post a Comment