从(FileUpload1.PostedFile.FileName)F:\Documents and Settings\WXZ\My Documents\千千all.ttp中获取文件名: 千千all

解决方案 »

  1.   


    截取一下就行了啊
    如果字符串是
     string str=@"F:\Documents and Settings\WXZ\My Documents\千千all.ttp";
                int s = str.LastIndexOf("\\")+1;
                int e = str.IndexOf(".");
                Console.WriteLine(str.Substring(s,e-s));
      

  2.   

    给你个我的例子if (this.flqualified.FileName != "")
            {
                string filename = GetFileName(flqualified.FileName);
                if (".doc)".IndexOf(filename.Substring(filename.Length - 4)) < 0)
                {
                    passTxt.Value = "合格证上传失败,文件扩展名必须为.doc";
                    return;
                }            string SysFile = Server.MapPath(@"qualified\" + filename);
                this.flqualified.PostedFile.SaveAs(SysFile);
                passTxt.Value = "合格证上传成功";
                ltqualified.Items.Clear();
                bind_qualified();
            }flqualified 为控件名
      

  3.   

     protected string GetFileName(string FileFullPath)
        {
           
            return FileFullPath.Substring(FileFullPath.LastIndexOf("\\") + 1);
        }自己看一下这个事得到文件名
      

  4.   


    string fileName = System.IO.Path.GetFileNameWithoutExtension(FileUpload1.PostedFile.FileName);
      

  5.   

    System.IO.Path.GetFileNameWithoutExtension(path);
      

  6.   

    IO里面提供的一个函数!!using System.IO;string ext=Path.GetExtension(fileName);
    switch(ext.ToLower())
    {
    case ".jpg":
    //code
    }