Click here to Skip to main content
15,895,777 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C#
foreach (FileInfo file in filearr)
{
    string name = file.Name;
    string s=file.Extension;
    string filepath = Path.GetFullPath(file.FullName);
    long filesize = file.Length;
    if (s == ".xls" && s == ".csv")
    {
        SqlCommand cmd1;
        cmd1 = new SqlCommand("[uspGetFilesinfo]", conn);
        cmd1.CommandType = CommandType.StoredProcedure;
        SqlParameter param11 = cmd1.Parameters.Add("@fileName", SqlDbType.NVarChar, 50);
        param11.Value = name;
        SqlParameter param12 = cmd1.Parameters.Add("@dirID", SqlDbType.Int);
        param12.Value = invid;
        SqlParameter param13 = cmd1.Parameters.Add("@dirName", SqlDbType.NVarChar, 50);
        param13.Value = txtinvname.Text;
        SqlParameter param14 = cmd1.Parameters.Add("@filesize", SqlDbType.Decimal, 15);
        param14.Value = filesize;
        SqlParameter param15 = cmd1.Parameters.Add("@filepath", SqlDbType.NVarChar);
        param15.Value = filepath;
        cmd1.ExecuteNonQuery();

    }

    else
    {

    }
}
Posted
Updated 26-May-15 23:09pm
v2
Comments
Andy Lanng 27-May-15 5:10am    
What?

(I was going to ask more, but I think "What?" is more than you have given us)

Read this and try again
Leo Chapiro 27-May-15 5:13am    
1. You have a wrong "if" statement: use if (s == ".xls" || s == ".csv") rather then && !
2. If statement is NOT a loop but a condition !

1 solution

Wrong if - statement:

C#
//if (s == ".xls" && s == ".csv")
if (s == ".xls" || s == ".csv")
 
Share this answer
 
Comments
Member 11527624 27-May-15 6:41am    
thanks it was solved before u commented ;)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900