// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-#if NET_2_0
-
+using System.Web;
namespace System.Web.Mail
{
public class RelatedBodyPart
{
- private string id;
- private string fileName;
+ string id;
+ string fileName;
public RelatedBodyPart (string id, string fileName)
{
this.id = id;
- this.fileName = fileName;
+ if (FileExists (fileName))
+ this.fileName = fileName;
+ else
+ throw new HttpException(500, "Invalid related body part");
}
public string Name {
get { return fileName; }
set { fileName = value; }
}
+
+ bool FileExists (string fileName)
+ {
+ //I am handling local files only . Not sure how URL's
+ //need to be handled.
+ try {
+ System.IO.File.OpenRead (fileName).Close ();
+ return true;
+ } catch (Exception) {
+ return false;
+ }
+ }
}
}
-#endif