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

FTP 上传 报异常 未能找到文件“C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\123.png


private int PicFileUpload(FileUpload myFile, string newFileName)
        {
            int upFile = 0;
            string picFileName = myFile.PostedFile.FileName;
            upFile = FtpUpload.FtpFileUpload("********/web/Content/images/mob", "123456", "123456",
                picFileName, newFileName, "");
            return upFile;
        }



感觉就是没有获取 页面上传控件中的绝对地址。

如果把string picFileName =@"D://aaa/aaa.jpg"; 

这么是可以的。

为什么呢? 以前用这个方法是可以的,但不知道改了什么就不行了... --------------------编程问答-------------------- 路径错误或文件夹权限错误! --------------------编程问答-------------------- 取相对路经 --------------------编程问答-------------------- Server.Mapath("********/web/Content/images/mob/"); --------------------编程问答-------------------- Server.Mapath("********/web/Content/images/mob/"); --------------------编程问答--------------------      FtpWebRequest req = (FtpWebRequest)FtpWebRequest.Create(config.GetFtpUri(filePath));
            req.Credentials = config.Credentials;
            req.Method = WebRequestMethods.Ftp.UploadFile;

            Stream upstream = req.GetRequestStream();

            for (int byteData = this.FileContent.ReadByte(); byteData != -1; byteData = this.FileContent.ReadByte())
            {
                upstream.WriteByte((byte)byteData);
            }

            upstream.Close();
            req.GetResponse();
--------------------编程问答-------------------- Server.Mapath("********/web/Content/images/mob/"); --------------------编程问答-------------------- 在ASP.NET和WinForm中不一样,需要将相对URL路径或者URL路径转换成实际的物理路径。
Server.Mapath("********/web/Content/images/mob/");就是起这个作用的。 --------------------编程问答--------------------
引用 7 楼 zhoufoxcn 的回复:
在ASP.NET和WinForm中不一样,需要将相对URL路径或者URL路径转换成实际的物理路径。
Server.Mapath("********/web/Content/images/mob/");就是起这个作用的。


大哥,这是FTP 上传!!!!!!!!!!!!

"********/web/Content/images/mob" 就是: "www.aaaaaa.com/web/Content/images/mob"

这样还需要Server.Mapath()??????????????

--------------------编程问答-------------------- ... --------------------编程问答-------------------- 绝对路径看下 和 文件夹权限 --------------------编程问答-------------------- 学
补充:.NET技术 ,  ASP.NET
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,