我想使用上傳YouTube上的視頻this code文件上傳錯誤的文件路徑
我已經
if (FileUpload1.HasFile)
{
var filePath = FileUpload1.FileName; // Replace with path to actual movie file.
using (var fileStream = new FileStream(filePath, FileMode.Open))
{
var videosInsertRequest = youtubeService.Videos.Insert(video, "snippet,status", fileStream, "video/*");
videosInsertRequest.ProgressChanged += videosInsertRequest_ProgressChanged;
videosInsertRequest.ResponseReceived += videosInsertRequest_ResponseReceived;
await videosInsertRequest.UploadAsync();
}
}
改變var filePath = @"REPLACE_ME.mp4";
但我發現了一個錯誤,這是錯的路徑
我該如何解決這個問題? 另一個我曾嘗試:
var filePath = FileUpload1.PostedFile.FileName;
var filePath = FileUpload1.PostedFile.ToString();
var filePath = Path.GetFileName(FileUpload1.FileName);
但同樣的結果..
如果您如果不提供完整路徑,系統將使用當前運行在C:\ Program Files(x86)\ IIS Express上的應用程序的當前路徑,這顯然是IIS Express。解決方案:在保存之前提供完整路徑。 – 2014-10-16 12:03:53