当前位置:编程学习 > C#/ASP.NET >>

System.IO.Directory.CreateDirectory 不支持URI格式

 ImageWebService web = new ImageWebService();
            if(this.FileUpload1.HasFile)
            {
                try
                {
                   User_Photo model=new User_Photo ();

                    string picName = this.FileUpload1.FileName;
                    string endpicname = picName.Substring(picName.LastIndexOf("."));
                    //从配置文件中读取图片的格式

                    string picformat = web.GetImageFormats(picName); ;
                    //判断上传的图片格式是否和配置文件中的相匹配
                    if (!picformat.Contains(endpicname.ToLower()))
                    {
                        Util.Show(this.Page, "请选择正确的图片格式!");
                        return;
                    }
                    string FilePathOld = web.GetWebSite()+"/"+web.GetUploadFile()+"blog/photo/";
                 
                    if (!System.IO.Directory.Exists(FilePathOld))
                    {
                        System.IO.Directory.CreateDirectory(FilePathOld);
                    }
                   
                    Random ra = new Random(DateTime.Now.Millisecond);
                    string picradname = ra.Next() + endpicname;
                    this.FileUpload1.SaveAs(FilePathOld + picradname);

                    model.UserP_PhotoName_CN = this.txtTitle.Text.Trim();
                    model.UserA_AlbumID = Convert.ToInt32(this.DropDownList1.SelectedValue.ToString());

                    model.UserP_PhotoUrl = web.GetUploadFile() + "blog/photo/" + picradname;
                    model.UserP_PhotoAddDate = DateTime.Now;
                    model.UserP_PhotoDesc = this.txtdesc.Text.Trim();
                    User_Info info = new User_Info();
                    info.UserID = 1;
                    Session["userinfo"] = info;
                    User_Info  user= Session["userinfo"] as User_Info;
                    if (user != null)
                    {
                  
                        model.UserI_UserID = user;
                        bool falg = new UserPhotoBLL().AddUserPhoto(model);
                        if (falg)
                        {
                            JavaScriptManager.Alert("ok");
                        }
                    }
                    else
                    {
                        Response.Redirect("index.aspx",false);
                    }
                 
                }
                catch (Exception ex)
                {
                   // sl.AddLog(Request.Path, "异常", Page.Request.UrlReferrer.ToString(), Request.UserHostAddress, "下载资源描述添加失败!", Server.MachineName);
         }
    FilePathOld =http://localhost:1942/Files/blog/photo/  调试后的路径,我建立站点的时候建立了两个站点,
现在想通过一个站点,上传到另外一个站点上去,通过webservice但是总是报“ 不支持URI格式”
大家帮忙看一下,
                 --------------------编程问答-------------------- 必须使用windows文件格式,使用Server.MapPath("~/Files/blog/photo/")转成本地路径 --------------------编程问答--------------------
引用 1 楼 net_lover 的回复:
必须使用windows文件格式,使用Server.MapPath("~/Files/blog/photo/")转成本地路径


ok --------------------编程问答-------------------- 呵呵,问题已经解决了,还是要谢谢大家
补充:.NET技术 ,  .NET技术前瞻
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,