| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 550 人关注过本帖
标题:帮忙解决一下“Myweb.Manage.ProductEdit”不实现接口成员“Myweb.Componen ...
只看楼主 加入收藏
incoolwen
Rank: 1
等 级:新手上路
帖 子:58
专家分:0
注 册:2007-6-21
结帖率:90.91%
收藏
已结贴  问题点数:20 回复次数:2 
帮忙解决一下“Myweb.Manage.ProductEdit”不实现接口成员“Myweb.Components.IUploadFile.UploadImg(s
代码如下:
接口定义用方法:
namespace
{
    interface IUploadFile
    {
       // bool DelFile(string file);
        string UploadImg(string UploadPath_s, System.Web.HttpPostedFile Upfile);
    }

    public class UploadFile : Page, IUploadFile
    {
        /// <summary>
        /// 上传文件
        /// </summary>
        /// <param name="UploadPath_s">路径</param>
        /// <param name="UploadType_s">类型</param>
        /// <param name="kj">控件名</param>
        /// <returns>imgurl</returns>
        public string UploadImg(string UploadPath_s, HttpPostedFile Upfile)
        {
            string imgurl = "";
            double upload_file_size = System.Configuration.ConfigurationManager.AppSettings["Upload_file_size"].ToFloat();
            string UploadType = System.Configuration.ConfigurationManager.AppSettings["Upload_img_type"];
            string UploadPath = UploadPath_s;

            int len = Upfile.ContentLength;

            if (len > 0)
            {
                if (len > 1024 * 1024 * upload_file_size)
                {
                    return "size";
                }

                string filePath = Upfile.FileName;
                string extname = filePath.Substring(filePath.LastIndexOf(".")).ToLower();

                if (!UploadType.Contains(extname))
                {
                    return "type";
                }

                string filename = string.Format("{0:yyyyMMddHHmmss}", DateTime.Now);

                imgurl = UploadPath + filename + extname;//图片路径
                if (!Directory.Exists(Server.MapPath("~/" + UploadPath)))
                    Directory.CreateDirectory(Server.MapPath("~/" + UploadPath)); //如果目录不存在则建立

                string savepath = Server.MapPath("~/" + UploadPath) + filename + extname;
                Upfile.SaveAs(savepath);

                return imgurl;
            }
            return "";
        }
     }
 }
接口调用:
public partial class ProductEdit : Base_Page, IUploadFile
    {
        #region 上传图片
        private bool UploadImg()
        {
            IUploadFile U = new UploadFile();
            string imgpath = U.UploadImg("UpLoadFile/Pro/", pic.PostedFile);
            if (imgpath != null)
            {
                ViewState["ImgUrl"] = imgpath;
                return true;
            }
            else
            {
                return false;
            }
        }
        #endregion
    }
搜索更多相关主题的帖子: interface 上传文件 public 接口 
2012-07-02 11:42
incoolwen
Rank: 1
等 级:新手上路
帖 子:58
专家分:0
注 册:2007-6-21
收藏
得分:0 
问题解决了
public class UploadFile : Page, IUploadFile
改成
public class UploadFile : Page

但我又多了一个疑问,为什么不能继承 IUploadFile接口》?

2012-07-02 14:31
lcawen
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:41
专家分:184
注 册:2011-8-11
收藏
得分:20 
IUploadFile 接口的成员你没有完全实例化吧
2012-07-02 17:19
快速回复:帮忙解决一下“Myweb.Manage.ProductEdit”不实现接口成员“Myweb.Com ...
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.027401 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved