为什么我的code文件保存到C盘? [英] Why can't my code save files to C drive?

查看:352
本文介绍了为什么我的code文件保存到C盘?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我救了我的图片文件夹中的 SiteImages 驻留项目的根目录中,但我想将它放在我的C盘上,并要保存和访问的照片从那里即 C:/ SiteImages ,但我想不出

code:(上传)

 字符串文件名= Path.GetFileName(FileUpload1.FileName);
FileUpload1.PostedFile.SaveAs(使用Server.Mappath(〜/ SiteImages /)+文件名);

code:(访问)

 字符串的文件路径=新的URI(使用Server.Mappath(〜/ SiteImages /))绝对URI。

请帮忙,使其在C盘的工作

更新:问题是现在的GridView从采摘C驱动器的图片。

老:

 < IMG SRC ='.. / SiteImages /<%#的eval(PersonalInfoEmployeePicture)%>' WIDTH =20高度=20的onmouseover =ShowFull(本)的onmouseout =ShowActual(本)/>


解决方案

只是删除​​图像源的开始 ..

 < IMG SRC =/ SiteImages /<%#的eval(PersonalInfoEmployeePicture)%>' WIDTH =20高度=20的onmouseover =ShowFull(本)的onmouseout =ShowActual(本)/>

如果你仍在使用低于code保存上传的图片

  FileUpload1.PostedFile.SaveAs(使用Server.Mappath(〜/ SiteImages /)+文件名);

I am saving my image to a folder SiteImages that resides within project root but I want to place it on my C drive and want to save and access pictures from there i.e. C;/SiteImages but I can't figure out

Code: (Upload)

string fileName = Path.GetFileName(FileUpload1.FileName);
FileUpload1.PostedFile.SaveAs(Server.MapPath("~/SiteImages/") + fileName);

Code: (Access)

string FilePath = new Uri(Server.MapPath("~/SiteImages/")).AbsoluteUri;

please help to make it work within C drive

UPdate: problem is with gridview picking picture from C drive now.

Old:

<img src='../SiteImages/<%# Eval("PersonalInfoEmployeePicture") %>' width="20" height="20" onmouseover="ShowFull(this)" onmouseout="ShowActual(this)" />

解决方案

just remove the begin .. in image source

<img src='/SiteImages/<%# Eval("PersonalInfoEmployeePicture") %>' width="20" height="20" onmouseover="ShowFull(this)" onmouseout="ShowActual(this)" />

If you still using below code to save uploaded images

FileUpload1.PostedFile.SaveAs(Server.MapPath("~/SiteImages/") + fileName);

这篇关于为什么我的code文件保存到C盘?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆