there are nothing is inside my test002 folder, by right my output should be is “nothing is inside the folder”,but after compile there are nothing prompt.
what i want to do is if there are any .doc file is inside my folder, just upload it
if there are nothing is inside the folder, ask user to upload .doc to required folder.
protected void Button3_Click(object sender, EventArgs e)
{
try
{
string[] chkUserResume = Directory.GetFiles(HttpContext.Current.Server.MapPath(@"~/Enduser/test002/"), "*.doc");
if (chkUserResume!=null)
{
foreach (string name in chkUserResume)
{
Response.Write(name + " is exist");
}
}
else
{
Response.Write("nothing is inside the folder");
}
}
catch (Exception ex)
{
Response.Write(ex.Message.ToString());
}
}
The
nullkeyword means that the variable is not set to any real value, which is different from an empty array.In this case,
chkUserResumewill never be null, it will be an empty array. You should check thatchkUserResume.Lengthis 0 instead.