C# 应该是蛮简单的一个问题

lisa9342 lisa9342 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区

//根据用户选择来确定要被发送的文件格式
ArrayList sendType = new ArrayList();
if (Utils.xml.ToString() == "true")
sendType.Add(".xml");
if (Utils.eml.ToString() == "true")
sendType.Add(".eml");
if (Utils.doc.ToString() == "true")
sendType.Add(".doc");
if (Utils.docx.ToString() == "true")
sendType.Add(".docx");
if (Utils.xls.ToString() == "true")
sendType.Add(".xls");
if (Utils.xlsx.ToString() == "true")
sendType.Add(".xlsx");
if (Utils.txt.ToString() == "true")
sendType.Add(".txt");
if (Utils.pdf.ToString() == "true")
sendType.Add(".pdf");
if (Utils.rar.ToString() == "true")
sendType.Add(".rar");
if (Utils.zip.ToString() == "true")
sendType.Add(".zip");

foreach (string f in files)
{
//先检查文件名
string path = f;
string newpath = path;
string fullname = Path.GetFileName(path);//返回文件名和后缀名
string name = Path.GetFileNameWithoutExtension(path);//返回文件名
string extn = Path.GetExtension(path);//返回后缀名
if (!sendType.Contains(extn))
break;
byte[] Bytes = System.Text.Encoding.Default.GetBytes(fullname);//获得文件名+后缀名的字节数组
byte[] nameBytes = System.Text.Encoding.Default.GetBytes(name);//获得文件名的字节数组
byte[] extnBytes = System.Text.Encoding.Default.GetBytes(extn);//获得后缀名的字节数组
string newname = fullname;//新(文件名+后缀名)
……


我用break调试的结果是,如果文件格式不对应的话就又从文件夹的第一个文件开始遍历,而我想不对应的时候就不往下进行其他操作,再从下一个文件检查,该用什么语句?
...全文
评论 8
收藏 已收藏
分享
返回顶部
lisa9342
C# 111,130 成员 642,541 内容