0

I would like to attach a file on a web page and save it in TFS.

I am using the asp.net fileupload control to save the file . Can anyone please tell me how I can insert the accessed file from fileupload control into tfs ?

Here is my code :

   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"));
        }
       }
CodeNinja
  • 3,188
  • 19
  • 69
  • 112

1 Answers1

0

Try this, it worked for me in aspx.vb world :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))