尝试了很多替代方案,但遇到filenotfound
错误。我需要在文本框中使用完整路径并在Youtube上上传视频。
public void UploadFileonYouTube()
{
string filename = FileUpload1.FileName;
string fullpath = Path.Combine(Directory.GetCurrentDirectory(), filename);
YouTubeRequest request = new YouTubeRequest(settings);
Video newVideo = new Video();
newVideo.Title = "Demo";
newVideo.Tags.Add(new MediaCategory("Animals", YouTubeNameTable.CategorySchema));
newVideo.Description = "You tube Api Integration Demo.";
newVideo.YouTubeEntry.Private = false;
newVideo.YouTubeEntry.MediaSource = new MediaFileSource(fullpath, "video/x-ms-wmv");
request.Upload(newVideo);
//@"C:\head_rush4.wmv"
}
设计:Fileupload
控制上传文件。
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:FileUpload ID="FileUpload1" runat="server" />
<asp:Button ID="Button2" runat="server" Text="Upload on YouTube" OnClick="Button2_Click1" />
</div>
</form>
</body>
</html>
答案 0 :(得分:0)
使用enctype="multipart/form-data"
表单。
string fullpath = FileUpload1.FileName;
上面的代码只提供了文件名,而不是文件路径。 MSDN Link