110,566
社区成员
发帖
与我相关
我的任务
分享
//根据用户选择来确定要被发送的文件格式
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;//新(文件名+后缀名)
……