Where on the server is the file?
The first one works because you're referencing an existing file. The second one doesn't work likely because it can't find that file relative to whatever the current path is. You'll probably want to be more explicit with the path. The third one definitely won't work because that's not a file, it's a URL. (HTTP isn't a file system.)
Is the "Images" folder in the root of the application? Try prepending the second version with a "~"
to indicate that:
Image image = Image.FromFile("~/Images/sf.gif");
If the "Images" folder can change from something more than just the root of the application, you can also use a config setting to indicate the location of the images. Something as simple as this:
<add key="imagesRoot" value="C:\Users\Nico\Desktop\Project\MvcApplication1\MvcApplication1\Images\" />
And then you can use the Path
object to build a more complete path:
Image image = Image.FromFile(Path.Combine(ConfigurationManager.AppSettings["imagesRoot"], "sf.gif"));
For just the images folder of a website that might be overkill, but it's certainly flexible. And then you can point it to any folder via the config file whenever you need to change it or deploy it to a different server.