Search code examples
c#exceptionftpurifileinfo

Why is my URI not supported? FileInfo Argumentexception


I'm very confused about my code right now. I have a CarPhoto Object and in that object is a PhotoList list. In that list is a link to a photo, which is located on my FTP server.

When I try to delete the file, I get this message:

An unhandled exception of type 'System.ArgumentException' occurred in mscorlib.dll

Additional information: URI formats are not supported.

Here's the code:

private void delete_Button_Click_1(object sender, EventArgs e)
{
    DialogResult result = MessageBox.Show("Wilt u deze foto echt verwijderen?", "Foto verwijderen", MessageBoxButtons.YesNo);
    if (result == DialogResult.Yes)
    {
        int index = imageLinkList.SelectedIndex;
        CarPhoto photo = car.PhotoList[index];
        FileInfo fi = new FileInfo(photo.Photolink); //The exception gets thrown here.The link is: http://pqrojectqars.herobo.com/Images/Fiat/Punto/Wit/40.jpg
        string extension = fi.Extension;
    }
}

Can someone help me out?


Solution

  • Thanks guys, but I already found a solution. The FTP answers you guys are giving me was already in the code, I just had to find the extension of the file. it's solved.