110,538
社区成员
发帖
与我相关
我的任务
分享
FileInfo x =new FileInfo(@"C:\Documents and Settings\Administrator\桌面\ybbm.xls");
string FileName = x.Name;
Regex re = new Regex("\\([^\\]*?)\.xls",RegexOptions.None);
MatchCollection matchMade = null;
matchMade = re.Matches("yourStr");
foreach (Match matchMade0 in matchMade)
{
for (int index = 1; index < matchMade0.Groups.Count; index++)
{
MessageBox.Show(matchMade0.Groups[index].Value); //ybbm
}
}
string str = "C:\\Documents and Settings\\Administrator\\桌面\\ybbm.xls";
int number1 = str.LastIndexOf("\\");
int number2 = str.LastIndexOf(".");
string newstr = str.Substring(number1+1,number2-number1-1);
Response.Write(newstr);
//ybbm
string[] fileStrs = txtFileName.Text.Split(char.Parse(@"\"));
string sheetName = fileStrs[fileStrs.Length - 1].Replace(".xls", "").Replace(".XLS", "");
System.IO.Path.GetFileNameWithoutExtension(txtFileName.Text);