Server.MapPath()方法(找不到路径错误的一部分) [英] Server.MapPath() Method (Could not find a part of the path Error)

查看:381
本文介绍了Server.MapPath()方法(找不到路径错误的一部分)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我将项目上传到我们的生产服务器.在开发过程中,它运行良好.

所以问题是;当用户登录时,我有一个功能,该功能将写入文件.但是我遇到了这个错误;

找不到路径``c:\ windows \ system32 \ inetsrv \ XMLs \ Requests \ Log(09.14.2011 3.15 PM).xml''的一部分.
在我的web.config中,我添加了以下内容:

Hello guys,

I uploaded my project to our production server. While I am developing it was working fine.

So the problem is; when a user logs in I have a function and this function writes to a file. But I am having this error;

Could not find a part of the path ''c:\windows\system32\inetsrv\XMLs\Requests\Log(09.14.2011 3.15 PM).xml''.
In my web.config I have added this:

<identity impersonate="true" />

>

我正在使用StreamWriter将其写入文件和我使用的路径
"./XMLs/Requests/Log/[在这里我写文件名]"我也曾尝试替换.".带有〜",例如〜/XMLs/Requests/Log/[在这里我写文件名]"

我已检查服务器中是否存在"/XMLs/Requests/Log/"路径.

我想念一些东西.关于这个问题有人可以帮我吗?谢谢



I am using the StreamWriter to write it to a file and the path I used
"./XMLs/Requests/Log/[Here I write the file name]" I have also tried replacing "." with "~" like "~/XMLs/Requests/Log/[here I write the file name]"

I have checked the "/XMLs/Requests/Log/" path is existing in the server.

I am missing something. Can somebody help me regarding to the issue? Thanks

推荐答案

如果您使用的是../folder1/folder2 ...或~/folder1/folder2 ...,则这些文件夹必须作为子文件夹存在于主网站文件夹中.因此 Server.Map(path) [
If you are using ../folder1/folder2 ... or ~/folder1/folder2 ..., the folders have to exist in your main website folder as a sub folder. So Server.Map(path)[^] works for these cases only. But if you trying to access as an absolute path, then you must specify the full path of the file. Other thing you may have to check is either you are allowed to write/modify a file in the deployed server.

I hope this will help you well.


这篇关于Server.MapPath()方法(找不到路径错误的一部分)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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