|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
check if image or file existsI want to check if a certain file or image exists. The picture exists when I use th eurl in my IE, but in my C# code, the if statement returns false. Is there another way to do this? string PictureUrl = "http://www.lessius-ho.be/webapp/personeelsindex/images/543.jpg"; if (File.Exists(PictureUrl)) { imgFotoPersoon.ImageUrl = PictureUrl; imgFotoPersoon.Visible = true; } else { imgFotoPersoon.Visible = false; } thanks in advance, Filip De Backer Not tested but you could try something like this:
Dim objResponse As Net.HttpWebResponse Dim objRequest As Net.HttpWebRequest = Net.WebRequest.Create(URL) objRequest.Method = "GET" objResponse = objRequest.GetResponse() Show quoteHide quote "Filip De Backer" wrote: > Hi everyone, > > I want to check if a certain file or image exists. > The picture exists when I use th eurl in my IE, but in my C# code, the if > statement returns false. > Is there another way to do this? > > string PictureUrl = > "http://www.lessius-ho.be/webapp/personeelsindex/images/543.jpg"; > if (File.Exists(PictureUrl)) > { > imgFotoPersoon.ImageUrl = PictureUrl; > imgFotoPersoon.Visible = true; > } > else > { > imgFotoPersoon.Visible = false; > } > > thanks in advance, > > Filip De Backer This sounds good, but if the URI is incorect this will throw an
exception. You should use a "try catch" structure to return a boolean. Here is a sample code close to your problem : http://oraclevsmicrosoft.blogspot.com/2005/06/web-crawlerregular-expressions-and.html (look for the "loadUrl" method) Hope this helps Marc Boizeau http://oraclevsmicrosoft.blogspot.com Show quoteHide quote "=?Utf-8?B?SGFyb2xkcw==?=" <Haro***@discussions.microsoft.com> wrote in message news:<6B638233-5CFB-448C-A7CC-019D5469828F@microsoft.com>... > Not tested but you could try something like this: > > Dim objResponse As Net.HttpWebResponse > Dim objRequest As Net.HttpWebRequest = Net.WebRequest.Create(URL) > objRequest.Method = "GET" > objResponse = objRequest.GetResponse() > > > "Filip De Backer" wrote: > > > Hi everyone, > > > > I want to check if a certain file or image exists. > > The picture exists when I use th eurl in my IE, but in my C# code, the if > > statement returns false. > > Is there another way to do this? > > > > string PictureUrl = > > "http://www.lessius-ho.be/webapp/personeelsindex/images/543.jpg"; > > if (File.Exists(PictureUrl)) > > { > > imgFotoPersoon.ImageUrl = PictureUrl; > > imgFotoPersoon.Visible = true; > > } > > else > > { > > imgFotoPersoon.Visible = false; > > } > > > > thanks in advance, > > > > Filip De Backer
Strange Error when viewing page
Disable Submit Button get the value of dropdownList Target property of ASP hyperlink? View DataSet Relational Data Wich is the best control Inline Expression Resolution TreeView ASP.Net subtree.all is null or not an object -- Pls HELP! reset input screen DataGrid edit mode |
|||||||||||||||||||||||