0
namespace WebApplication4
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnAdd_Click(object sender, EventArgs e)
        {
            if (upImage.HasFile)
            {
                if (CheckFileType(upImage.FileName))
                {
                    string fielPath = " !/UploadImages/" + upImage.FileName;
                    upImage.SaveAs(MapPath(filePath));
                }

            }

        }


        bool CheckFileType(string fileName)
{
    string ext = Path.GetExtension ( fileName);
    switch (ext.ToLower()) 
{
    case ".gif" :
    return true; 
    case ".png:" :
    return true;
        case ".jpg" :
    return true;
    case " .jpeg" : 
    return true ;
    default :
    return false ; 
}
}
        void Page_Prerender()
        {
            string upFodler = MapPath("~/UploadImages/");
            DirectoryInfo dir = new DirectoryInfo(upFolder);
            dlstImages.DataSouce = dir.GetFiles();
            dlstImages.DataBind();

        }
    }
}

Error 1 The name 'filePath' does not exist in the current context C:\Users\se7olutionyg\Documents\Visual Studio 2008\Projects\WebApplication4\WebApplication4\Default.aspx.cs 30 44 WebApplication4

this is from the text book, i understand how the system work , but don't know what do they means by filePath
Is that the way we declare the path where the pix are located
second, can anybody explain the keyword,
DirectoryInfo,DirectoryInfo(upFolder);
DataSouce

3
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by mail2saion
0

Spelling mistake in the variable declaration 'string fielPath'.

Change line 16 in your code as below

string filePath = " !/UploadImages/" + upImage.FileName;

Edited by Ramesh S: n/a

0
void Page_Prerender()
        {
            string upFodler = MapPath("~/UploadImages/");
            DirectoryInfo dir = new DirectoryInfo(upFolder);
            dlstImages.DataSouce = dir.GetFiles();
            dlstImages.DataBind();

how about those stuff?
what should i put in directory info,
datasource,
is taht the source of the image file or what?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.