使用文件上载控件上载文件并将文件传递到对象/Web 服务



我想在网页上附加一个文件并将其保存在 TFS 中。

我正在使用 asp.net 文件上传控件来保存文件。 任何人都可以告诉我如何从文件上传插入访问的文件 控制到 TFS ?

这是我的代码:

   protected void FormView1_ItemInserting(object sender, FormViewInsertEventArgs e)
   {
       FileUpload fu = (FileUpload)FormView1.FindControl("FileUpLoad1");
        if (fu.HasFile)
        {
       // I want to know the code changes to the line below :               
        workitem.Attachments.Add(new Attachment("file accessed from file upload", "comment"));
        }
       }

试试这个,它在aspx.vb世界中对我有用:o)Rgds,马夫。

 Dim objFSO, objFolder
 objFolder = "D:dump"
 objFSO = CreateObject("Scripting.FileSystemObject")
 objFSO.CreateFolder(objFolder)
 System.IO.Directory.SetCurrentDirectory(objFolder.ToString)
 Dim physicalFolder = System.IO.Directory.GetCurrentDirectory().ToString
 Dim fileName As String = System.IO.Path.GetFileNameWithoutExtension(FileUploadControl.FileName)
 Dim extension As String = System.IO.Path.GetExtension(FileUploadControl.FileName)
 FileUploadControl.PostedFile.SaveAs(System.IO.Path.Combine(physicalFolder, _ 
  fileName + extension))

最新更新