public static string GetFilePath(int photoId, bool forUrl, PhotoSize size)
{
string result = null;
string filenameToken;
if (size == PhotoSize.Full)
filenameToken = "Lg";
else if (size == PhotoSize.Medium)
filenameToken = "Md";
else
filenameToken = "Sm";
SiteSettings s = SiteSettings.GetSharedSettings();
{
if (forUrl)
{
result = String.Format("{0}/{1}/{2}.{3}.jpg", ClassifiedsHttpApplication.SiteUrl, s.ServerPhotoUploadDirectory, photoId, filenameToken);
}
else
{
HttpContext context = HttpContext.Current;
if (context != null)
{
string serverDirectory = context.Server.MapPath(s.ServerPhotoUploadDirectory);
string file = String.Format("{0}.{1}.jpg", photoId, filenameToken);
result = Path.Combine(serverDirectory, file);
}
}
}
return result;
}