hi!
in my project i take images folder. i insert images that images are saved in my Images folder. my problem is when i insert same file name images means for example first i insert 1.jpeg and next i insert another image that file name is also 1.jpeg. this time first image is replaced with second 1.jpg. but my aim is first when i insert image it checks whether this filename is exits are not if exits give a message i.e., this filename is already exit. how can i solve this.
i take
If imgThumbnail.ImageUrl = Server.MapPath("~/ProductThumbnails/") Then
Response.Write("This Thumbnail Filename is Already Exits. please Rename The New Thumbnail filename")
End If
please help me. very urgent thank u sir.
Loading
Mohankumar SPosted Apr 3, 2012, 7:11 AM
Thanks for your valuable answer for me
keep in ur answer to web by mohan
Amit ChoudharyPosted Feb 25, 2010, 8:48 AM
if (System.IO.File.Exists(Server.MapPath("~/ProductThumbnails/"+FileName)))
Response.Write("This Thumbnail Filename is Already Exits. please Rename The New Thumbnail filename")
Raaj KumarPosted Feb 24, 2010, 8:52 AM
You can write a method which will check the available files and return a bool value. So using this you can verify the availability. A sample snippet is as follows,
protected bool IsFileExist(string fileName)
{
DirectoryInfo di=new DirectoryInfo (Server.MapPath("ProductThumbnails"));
FileInfo[] files=di.GetFiles();
foreach (FileInfo file in files)
{
if (file.Name==fileName)
{
return true;
}
}
return false;
}
Regards,
raaj