R
Ron
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
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