本文介绍了不进入if循环..的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
foreach (FileInfo文件 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
{
}
}
解决方案
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 { } }
解决方案
这篇关于不进入if循环..的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!