Invalid URI: The URI is empty. (VS 2010>>C# Help)

Beantwortet Invalid URI: The URI is empty. (VS 2010>>C# Help)

  • Donnerstag, 12. April 2012 23:31
     
     

    Hey, I was doing a little project of creating a Youtube Video Downloader,

    But when I run the Software everything was fine until I try to save the video file. Then this message came up;

    If you have any idea then please help me.


    • Bearbeitet Petventh Donnerstag, 12. April 2012 23:33
    •  

Alle Antworten

  • Donnerstag, 12. April 2012 23:46
     
     

    Hmm. The link takes me back here, is it supposed to?

    I'd say it's not got a URI when it expects one, but that's a pure guess based on not seeing any code and a mere hint of where it might be happening - somewhere in a save button click handler it seems. :)


    Regards David R
    ---------------------------------------------------------------
    The great thing about Object Oriented code is that it can make small, simple problems look like large, complex ones.
    Object-oriented programming offers a sustainable way to write spaghetti code. - Paul Graham.
    Every program eventually becomes rococo, and then rubble. - Alan Perlis
    The only valid measurement of code quality: WTFs/minute.

  • Freitag, 13. April 2012 09:23
     
     
    Please post your code so that we can see how the logic fits together. 
  • Samstag, 14. April 2012 22:19
     
     

    Thankx....

    The code is kinda long so,

    I'll put the portion which I believed might be the problem:

    And here's the full code: http://www.mediafire.com/?tvq3575p8f61e4r

    {
        public partial class Form1 : Form        
            
        {
            List<int> lstIndex = new List<int>();
            List<string> lstLinks = new List<string>();
            String flvlink = "", mp4link = "";
            int flv = 0, mp4 = 0;
            
            public Form1()
            {
                InitializeComponent();
            }

            private void DownloadLink(string dlink, string format)
            {
                SaveFileDialog dialog = new SaveFileDialog();
                dialog.Filter = format;

                try
                {
                    if (dialog.ShowDialog() == DialogResult.OK)
                    {
                        FileStream stream = new FileStream(dialog.FileName, FileMode.Create);

                        int bytesRead;
                        HttpWebRequest request = (HttpWebRequest)WebRequest.Create(dlink);
                        HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                        Stream dStream = response.GetResponseStream();
                        progressBar1.Maximum = (int)response.ContentLength;
                        
                        do
                        {
                           byte[] buffer = new byte[0x3e9];
                           bytesRead = dStream.Read(buffer,0,0x3e8); 
                           stream.Write(buffer,0,bytesRead);

                            if((progressBar1.Value + bytesRead) <= progressBar1.Maximum)
                            {
                                progressBar1.Value += bytesRead;                            
                            }
                            else 
                            {
                                progressBar1.Value = progressBar1.Maximum;
                            }

                            Application.DoEvents();                        
                        }
                        while(bytesRead != 0);

                        dStream.Close();
                        stream.Close();
                        MessageBox.Show("Download OK");

                    }

                }

                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);

                }
            
            }

    Sorry if it's really long.


    • Bearbeitet Petventh Samstag, 14. April 2012 22:22
    •  
  • Samstag, 14. April 2012 22:20
     
     
    Thanx..I post the code on this page so if u don't mind then can you take a look as well?
  • Montag, 16. April 2012 10:06
    Moderator
     
     Beantwortet

    Hi Petventh,

    Welcome to the MSDN forum.

    I tried your code but I can't reproduce the same error. If you want to download video you can check this: YouTube API Download Extension  .

    The YouTube API Download Extension makes it easier for developers, who are using the official YouTube API, to download videos from within their applications, by extending the Google GData .NET Client Library and adding the missing download support. It's developed in C#.

    You can also check the sample below.

    Downloading Youtube Videos C# WinForm

    http://www.codeproject.com/Articles/84903/Downloading-Youtube-Videos-C-WinForm

    Have a nice day.


    Bob Shen [MSFT]
    MSDN Community Support | Feedback to us

  • Montag, 16. April 2012 17:25
     
     

    Can you please provide sample data.

    It would be better to understand code and find error.

    Just message box is not sufficient.