c# 中读取文件路径问题

shenmixiaozi 2009-04-24 10:42:29
server.mappath() 在c/s架构中我用这个读取文件,但是提示初server不存在,引用页不对,是sqlserver的server
该如何读取?
...全文
221 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
pzlin 2009-04-24
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 llsen 的回复:]
引用 3 楼 wuyq11 的回复:
在winform里用Application.StartupPath
WEB里 Server.Mappath("")

对了
楼主别搞混了
[/Quote]

呵呵。。
llsen 2009-04-24
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 wuyq11 的回复:]
在winform里用Application.StartupPath
WEB里 Server.Mappath("")
[/Quote]
对了
楼主别搞混了
Tensionli 2009-04-24
  • 打赏
  • 举报
回复
Application.ExecutablePath();
Application.StartupPath();
冬你个冬 2009-04-24
  • 打赏
  • 举报
回复
呵呵 他们继承的东西都不一样 在WEB开发中 server 继承于page这个东东
freewind0521 2009-04-24
  • 打赏
  • 举报
回复
用Application.StartupPath+文件夹/文件
wuyq11 2009-04-24
  • 打赏
  • 举报
回复
在winform里用Application.StartupPath
WEB里 Server.Mappath("")
yangqidong 2009-04-24
  • 打赏
  • 举报
回复
有没有搞错?cs架构读取本地文件干嘛还要mappath
ericzhangbo1982111 2009-04-24
  • 打赏
  • 举报
回复
c/s架构?用这个
Path.GetFullPath(Assembly.GetExecutingAssembly().GetModules()[0].FullyQualifiedName);
L314896283 2009-04-24
  • 打赏
  • 举报
回复
学习
marvelstack 2009-04-24
  • 打赏
  • 举报
回复
读取文件路径的方法很多,尤其是在C/S架构下,
通过调用Process.GetCurrentProcess().MainModule.FileName可获得当前执行的exe的文件名。
Environment.CurrentDirectory
Directory.GetCurrentDirectory()
AppDomain.CurrentDomain.BaseDirectory
Application.StartupPath
Application.ExecutablePath
Assembly.GetExecutingAssembly
AppDomain.CurrentDomain.SetupInformation.ApplicationBase获取当前应用程序所在的路径。
http://www.cnblogs.com/xingd/archive/2005/03/21/123152.html
System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory()

(web)的是Server.MapPath("\\CMPdata.mdb")
System.Web.Hosting.HostingEnvironment.ApplicationVirtualPath


Directory.SetCurrentDirectory();

Directory.GetLogicalDrives();

Directory.GetCurrentDirectory();

111,126

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧