locked
youtube thumnail image not saving in to PC RRS feed

  • Question

  • User1447694405 posted

    Hi All,

              i try to save youtube thumnail image in my local pc by asp.net c# application. some of them are saving my pc. but some of them are not saving. why.?

         

     saving images  

    http://img.youtube.com/vi/8xthEGaywuk/1.jpg
    http://img.youtube.com/vi/jh-PnSxVFSI/1.jpg
    http://img.youtube.com/vi/8OYf79iu2VI/1.jpg

    not saving images

    http://img.youtube.com/vi/OMjAWg63ZKY/1.jpg
    http://img.youtube.com/vi/YmzQccIEef4/1.jpg

    below i giving my c# code

    a = a + 1;
    string connection = System.Configuration.ConfigurationManager.ConnectionStrings["TenantDataConnection"].ConnectionString.ToString();
    SqlConnection conn = new SqlConnection(connection);
    SqlCommand cmd;
    cmd = new SqlCommand("ConvertImage", conn);
    cmd.CommandType = System.Data.CommandType.StoredProcedure;

    //cmd.Parameters.Add("@imageconvert",System.Data.SqlDbType.Int,1,"1");
    if (a == 6) { a = 7; }
    SqlParameter tblvaluetype = cmd.Parameters.AddWithValue("@imageconvert", a);
    tblvaluetype.SqlDbType = System.Data.SqlDbType.Int;
    conn.Open();
    SqlDataReader dr = cmd.ExecuteReader();
    dr.Read();
    string value = dr[0].ToString();
    //string value2 = dr[1].ToString();
    conn.Close();
    string[] value3 = null;
    value3 = value.Split('/');
    string remoteUri = value;
    string fileName = value3[5], myStringWebResource = null;
    string filepathis = @"D:\Binu\Images\" + value3[4] + fileName;
    WebClient myWebClient = new WebClient();
    myStringWebResource = remoteUri;
    myWebClient.DownloadFile(myStringWebResource, filepathis);

    Friday, September 26, 2014 5:04 AM

Answers

  • User-417640953 posted

    Hi binumon03,

    Thanks for your post.

    According to your description and code provided, I understand you want to download images from youtube server using WebClient

    and save it to your server local file system.

    WebClient myWebClient = new WebClient();
    myStringWebResource = remoteUri;
    myWebClient.DownloadFile(myStringWebResource, filepathis);

    For downloading and saving, I see all about above code, you can debug it or using try catch statement and see

    what happened. Then you can find solution according to error message.

    Thanks.

    Best Regards!

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, September 28, 2014 3:42 AM