// 需要注意的是:txtServerPath文件夹有匿名可写的权限。
      // 可以自己定义新文件名字
      if(txtFileName.Text.Trim() == "" || txtServerPath.Text.Trim() == "")
      {
        MessageBox.Show("请输入你要上载的文件名字!","错误:", MessageBoxButtons.OK,
                                                         MessageBoxIcon.Information); 
      }
      else
      {
        /// 得到文件名,文件扩展名字,服务器路径
        string fileNamePath = txtFileName.Text.Trim();
        string uriString = txtServerPath.Text.Trim();
        string fileName = fileNamePath.Substring(fileNamePath.LastIndexOf("\\") + 1); 
        string fileNameExt = fileName.Substring(fileName.LastIndexOf(".") + 1);
        if(uriString.EndsWith("/") == false) uriString = uriString + "/";

解决方案 »

  1.   

    private void button2_Click(object sender, System.EventArgs e)
        {
          OpenFileDialog dlgOpenFile = new OpenFileDialog();
          dlgOpenFile.InitialDirectory = @"C:\";
          dlgOpenFile.ShowReadOnly = false;
          dlgOpenFile.ReadOnlyChecked = true;
          dlgOpenFile.Filter = "所有文件 (*.*)|*.*";
          if(dlgOpenFile.ShowDialog() == DialogResult.OK)
          {
            if(dlgOpenFile.ReadOnlyChecked == true)
            {
              txtFileName.Text = dlgOpenFile.FileName.ToString();
            }
          }
        }    private void button1_Click(object sender, System.EventArgs e)
        {
          // 需要注意的是:txtServerPath文件夹有匿名可写的权限。
          // 可以自己定义新文件名字
          if(txtFileName.Text.Trim() == "" || txtServerPath.Text.Trim() == "")
          {
            MessageBox.Show("请输入你要上载的文件名字!","错误:", MessageBoxButtons.OK,
                                                             MessageBoxIcon.Information); 
          }
          else
          {
            /// 得到文件名,文件扩展名字,服务器路径
            string fileNamePath = txtFileName.Text.Trim();
            string uriString = txtServerPath.Text.Trim();
            string fileName = fileNamePath.Substring(fileNamePath.LastIndexOf("\\") + 1); 
            string fileNameExt = fileName.Substring(fileName.LastIndexOf(".") + 1);
            if(uriString.EndsWith("/") == false) uriString = uriString + "/";
      

  2.   

    http://xml.sz.luohuedu.net/xml/ShowDetail.asp?id=D8F961C3-CBC1-4591-143D-236B572EB89Fhttp://xml.sz.luohuedu.net/xml/ShowDetail.asp?id=58EA3515-36F2-4FD9-AC89-EAF49F59816C
      

  3.   

    String namenoexten = Path.GetFileNameWithoutExtension(file);//文件名(没有扩展名)
    String name = Path.GetFileName(file);//文件名(包括扩展名)
    String exten = Path.GetExtension(file);//扩展名