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

时间:2014-11-24 00:50:28

标签: c# asp.net tfs webforms tfs-sdk

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

我正在使用asp.net fileupload控件来保存文件。             任何人都可以告诉我如何从fileupload插入访问过的文件             控制到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"));
        }
       }

1 个答案:

答案 0 :(得分:0)

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

 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))