我的所有网站文件本来都存在一个叫wp的文件夹中.这个文件夹在wwwroot/wp 后来根据需要我把所有wp文件夹里的东西都拉了出来放在了wwwroot下.结果上传文件的目录怎么改都不变.都是在wp下.源文件如下:
if(myfile.PostedFile!=null)
{
//取得文件名
string name = myfile.PostedFile.FileName;
//取得最后一个"."
int i = name.LastIndexOf(".");
//取得扩展名
string newext=name.Substring(i);
//根据日期为文件命名,确定不重复
DateTime now = System.DateTime.Now;
string newname = now.DayOfYear.ToString()+myfile.PostedFile.ContentLength.ToString();
//保存文件到所要的目录
myfile.PostedFile.SaveAs(Server.MapPath("d:\\local\\wwwroot\\ycch\\wwwroot\\mpic\\" + newname + newext));
this.fname.Text = "d:\\local\\wwwroot\\ycch\\wwwroot\\mpic\\" + newname + newext;
//连接数据库}mpic是wp下的一个文件夹.但我怎么改这个路径.不管是用根目录还是用//mpic都无法改变上传路径,总是报错说d:\\local\\wwwroot\\ycch\\wwwroot\\wp\\mpic\\ 路径错误,我没有加wp啊?? 怎么改不了呢??谁能帮助解决一下谢谢了!!跪求.
if(myfile.PostedFile!=null)
{
//取得文件名
string name = myfile.PostedFile.FileName;
//取得最后一个"."
int i = name.LastIndexOf(".");
//取得扩展名
string newext=name.Substring(i);
//根据日期为文件命名,确定不重复
DateTime now = System.DateTime.Now;
string newname = now.DayOfYear.ToString()+myfile.PostedFile.ContentLength.ToString();
//保存文件到所要的目录
myfile.PostedFile.SaveAs(Server.MapPath("d:\\local\\wwwroot\\ycch\\wwwroot\\mpic\\" + newname + newext));
this.fname.Text = "d:\\local\\wwwroot\\ycch\\wwwroot\\mpic\\" + newname + newext;
//连接数据库}mpic是wp下的一个文件夹.但我怎么改这个路径.不管是用根目录还是用//mpic都无法改变上传路径,总是报错说d:\\local\\wwwroot\\ycch\\wwwroot\\wp\\mpic\\ 路径错误,我没有加wp啊?? 怎么改不了呢??谁能帮助解决一下谢谢了!!跪求.
解决方案 »
- asp.net单点登录
- 怎么实现“相关文章”功能
- 组合两个字符串的问题
- 经验之谈 前辈指点
- 网页传过来的值,获取后却是空的,求解
- 如何让datagrid的某些列在一定条件下为隐藏,急~~~
- 在用户控件中如何使用Session
- 各路大虾,来帮帮手!!!!
- (高分)母版中使用repeater控件的问题..!在线等.!急.!
- 请问有没有国外的比较人气比较旺的有关.net的技术论坛或是聊天室?
- 求教在asp.net添加xml的子节点问题??????
- if DateDiff("d",vEditTime,date())<1 then Response.Write"<img src=images/new.gif border=0>"
/// 获取当前站点的根路径的虚拟路径(Web方式下有效),不包括最后的路径符号。
public static string WebVirtualPath
{
get
{
if (System.Web.HttpContext.Current != null && m_strVirtualPath == null)
{
m_strVirtualPath = System.Web.HttpContext.Current.Request.ApplicationPath;
if (m_strVirtualPath != null)
{
m_strVirtualPath = m_strVirtualPath.TrimEnd(new char[] { '/', '\\' });
}
}
return m_strVirtualPath;
} }
这种形式,就不用再 Server.MapPathServer.MapPath的作用是把相对路径如: ../aa/转换成绝对路径.
然后设置断点看看路径到底是什么?