Generic filehandler method
- From: "Ron" <rs_herhuth@xxxxxxxxx>
- Date: Thu, 15 May 2008 09:23:27 -0400
I am trying to build a generic static method that will return a specified type from a method. My problem is that I need to return say an image from the method...and I'm having trouble understanding how to do this.
This is what I have so far...(The new Image is hardcoded right now...I would like to abstract that out)
private T GetFileFromFileSystem<T>(string filePath, string fileNameWithoutExtension)
{
string tempExtension = "";
if (Directory.Exists(filePath))
{
if (Path.GetFileNameWithoutExtension(filePath + "\\" + imageNameWithoutExtension).ToString().Trim().Length > 0)
{
tempExtension = Path.GetExtension(filePath + "\\" + imageNameWithoutExtension);
return (T)(Object)new Bitmap(filePath + "\\" + imageNameWithoutExtension + "." + tempExtension);
}
else
{
return default(T);
}
}
}
Thanks for any help you might be able to provide,
Ron
.
- Follow-Ups:
- Re: Generic filehandler method
- From: Peter Duniho
- Re: Generic filehandler method
- From: mrshrinkray@xxxxxxxxxxxxxx
- Re: Generic filehandler method
- Prev by Date: RE: How to Refresh Datagrid Control?
- Next by Date: Read MS Access
- Previous by thread: valid culturename check
- Next by thread: Re: Generic filehandler method
- Index(es):