【发布时间】:2015-07-27 17:47:52
【问题描述】:
尝试了很多替代方案,但卡在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>
【问题讨论】:
标签: c# youtube-api