我想在网页上附加一个文件并将其保存在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"));
}
}
答案 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))