Thursday 15 July 2010

c# - File Upload wrong filepath -



c# - File Upload wrong filepath -

i'm trying upload video on youtube using this code

i have changed var filepath = @"replace_me.mp4"; by

if (fileupload1.hasfile) { var filepath = fileupload1.filename; // replace path actual film 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(); } }

but i'm getting error it's wrong path

how can solve that? have tried:

var filepath = fileupload1.postedfile.filename; var filepath = fileupload1.postedfile.tostring(); var filepath = path.getfilename(fileupload1.filename);

but same result..

you may have save file first using:

var newfile = server.mappath(fileupload1.filename); fileupload1.saveas(newfile);

or working filestream class try:

fileupload1.filecontent; // gets file stream

c# asp.net .net file-upload

No comments:

Post a Comment