string aa="\UWPublic\UWPublic\FileDownLoad\FSCaptureSetup55.exe"
aa=aa.SubString("\"肆镇)
自己稍埋雹尘微修改一下即可弯禅
必须用上传控件,数据库里的是虚拟路径,文件必须物理上存在的。string size = FileUpload1.PostedFile.ContentLength.ToString()
double imageSize = Math.Round(float.Parse(size) / 1024, 1)
if (imageSize >150)
{
m.Show("你禅橡毁上传的图片大小为:" + imageSize.ToString() + "KB\\n\\n已超范围规定的150KB了"贺备)
return
}
string name = FileUpload1.FileName
string type = name.Substring(name.LastIndexOf(".") + 1).ToLower()
System.Guid guid = System.Guid.NewGuid()
string vsnewname = guid.ToString()//声称文件名,防止重复
FileUpload1.SaveAs(HttpContext.Current.Server.MapPath("~/file/" + vsnewname + "." + type))
string path = "~/file/" + vsnewname + "如山." + type
vb.net'控制台命令项目-取得或设置当前工作目录的完整限定路径
1. Environment.CurrentDirectory 'D:\project\test\bin\Debug
Environment.CurrentDirectory.Replace("\bin\Debug"盯烂, "") 'D:\project\test\bin\Debug
2. System.IO.Directory.GetCurrentDirectory
System.IO.Directory.GetCurrentDirectory.Replace("\bin\Debug", "")
'网络应用程序项目-取得或设置当前工作目录的完整限定路径
'获取承载在当前应用程序域中的应用程序的应用程序目录的物理驱动器路径。用于App_Data中获取
HttpRuntime.AppDomainAppPath.ToString()
'返回与Web服务器上的指定的虚拟路径相对的物理文件路径
defaultPage.Server.MapPath("")
defaultPage.Server.MapPath("~\")
'获取服务器上ASP.NET应用程序的虚拟应用程序根目录凯颤漏
defaultPage.Request.ApplicationPath.ToString()
以上获得的结果都是String类型的,很简单吧,接下洞游来怎么做你应该懂得。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)