|
Using the built-in FileUpload control, I want to perform error handling without this file.
My code looks like this:
HttpFileCollection uploadedFiles = Request.Files;
for (int i = 0; i <uploadedFiles.Count; i ++)
{
HttpPostedFile userPostedFile = uploadedFiles [i];
if (File.Exists (userPostedFile.FileName))
{
Upload
}
else
{
Error
}
}
The problem is that the absolute path of the file can be obtained at userPostedFile.FileName, such as: "C:\\Documents and Settings\\Admin\\Desktop\\aaa.txt", but whether the file exists or not, the result is false ..... . I don't know what's wrong with this method, or there are other better ways to determine if the file exists? Ask the master! |
|