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 GetFileFromFile System<T>(strin g filePath, string
fileNameWithout Extension)
{
string tempExtension = "";
if (Directory.Exis ts(filePath))
{
if (Path.GetFileNa meWithoutExtens ion(filePath + "\\" +
imageNameWithou tExtension).ToS tring().Trim(). Length 0)
{
tempExtension = Path.GetExtensi on(filePath + "\\" +
imageNameWithou tExtension);
return (T)(Object)new Bitmap(filePath + "\\" +
imageNameWithou tExtension + "." + tempExtension);
}
else
{
return default(T);
}
}
}
Thanks for any help you might be able to provide,
Ron
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 GetFileFromFile System<T>(strin g filePath, string
fileNameWithout Extension)
{
string tempExtension = "";
if (Directory.Exis ts(filePath))
{
if (Path.GetFileNa meWithoutExtens ion(filePath + "\\" +
imageNameWithou tExtension).ToS tring().Trim(). Length 0)
{
tempExtension = Path.GetExtensi on(filePath + "\\" +
imageNameWithou tExtension);
return (T)(Object)new Bitmap(filePath + "\\" +
imageNameWithou tExtension + "." + tempExtension);
}
else
{
return default(T);
}
}
}
Thanks for any help you might be able to provide,
Ron
Comment