用StreamWriter写文件时,“访问被拒绝” ,我的系统是2003的 请教大家,用StreamWriter写文件时,“访问被拒绝” ,我的系统是2003的,这个是怎么回事?怎么才能成功?谢谢了! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 权限问题,设置读写文件夹的权限~!=>我已经设置好了,而且还追加了NETWORKSERVECE,还是没有用!谢谢你!还有更好的解决方法吗? 没有写文件的权限,你需要配置ASP.NET用户在文件目录有写的系统权限 哪个路径下的?说详细一些.=>不是本地的任意一个共享文件夹下面没有写文件的权限,你需要配置ASP.NET用户在文件目录有写的系统权限=〉已经设置过了,可能没有设全谢谢大家 你怎么设置得权限?》确保你设置了写权限麽?这样设置权限:找到你要操纵的文件右击-安全-groups and user names(Users打钩)-permissions for users 里面得(full Control打钩) 一般说来是权限问题,添加everyone等的修改权限,或是你打开没有关闭,或是写的同时有程序在读 添加everyone这个用户到这个文件和文件夹的安全标签里!权限设置完全!在试试看 // strFileContent 要写的字符串// strTempFilePath = @"\\服务器具体地址"using (StreamWriter sw = new StreamWriter(strTempFilePath, false, Encoding.GetEncoding("shift-jis"))){ sw.Write(strFileContent);} 和远程服务器的设置有没有关系呢?应该还是权限的问题,如果就是本机的话,你看看.net安装后几个比如DEBUGUSER之类的帐户的权限 这是因为windows2003系统的安全性设置问题,系统把EveryOne用户经干掉了,你可以在网上找一下这权限修改问题。 asp.net 也是一个用户,要把它加进去. 模拟一个有管理员权限的用户。1,添加一个用户Demo密码Demo,并将这个用户加入到administrators组。2,在web.config下如下设置<configuration> <system.web> <identity userName="Demo" password="Demo"> </identity> </system.web></configuration> 回复人: renyu732(任宇) ( ) 信誉:100 2005-12-19 12:16:00 得分: 0 模拟一个有管理员权限的用户。1,添加一个用户Demo密码Demo,并将这个用户加入到administrators组。2,在web.config下如下设置<configuration> <system.web> <identity userName="Demo" password="Demo"> </identity> </system.web></configuration>=>这个可能是一种解决方法,我过会儿试一下。我后来调cmd.exe用net use映射的方法拷过去,也用到了用户名和密码,而且这样是成功了的。 //从初始化文件中读取上传文件的路径string strFilePath = SystemConfig.GetStringValue("C06", "FilePath");//从初始化文件中读取上传机器的UserNamestring strUserName = SystemConfig.GetStringValue("C06", "UserName");//从初始化文件中读取上传机器的密码string strPassword = SystemConfig.GetStringValue("C06", "Password");//文件名strFileName += DateTime.Now.ToString("yyyyMMddHHmmss") + ".csv";//零时文件名string strTempFilePath = string.Format(@"C:\{0}", strFileName);using (StreamWriter sw = new StreamWriter(strTempFilePath, false, Encoding.GetEncoding("shift-jis"))){ sw.Write(strFileContent);}string myCommon = string.Format(@"copy C:\{0} U:\{1}", strFileName, strFileName);Process process=new Process();process.StartInfo.FileName="cmd.exe";process.StartInfo.UseShellExecute=false;process.StartInfo.RedirectStandardInput = true;process.StartInfo.RedirectStandardOutput = true;process.StartInfo.RedirectStandardError = true;process.StartInfo.CreateNoWindow = true;process.Start();process.StandardInput.WriteLine(string.Format(@"net use U: {0} {1} /user:{2}", strFilePath, strPassword, strUserName));process.StandardInput.WriteLine(myCommon);process.StandardInput.WriteLine("exit");string myResult = process.StandardOutput.ReadToEnd();process.Close();if (File.Exists(strTempFilePath)){ File.Delete(strTempFilePath);} 设置写权限=>我感觉我的权限已经设了够大了,你能不能具体说一下怎么设?而且我已经把ASP.NET 和NETWORK SERVICE 都已经加了,都是同样的错啊! C# 如何设置滚动条的最小滚动量 帮我看看这个代码有什么问题? 使用shift+up/down实现多选 关于vs2008的安装 小弟写了一个关于网页自动登录的程序,遇到了问题,请各位大哥给我指点迷津 Assembly动态载入问题跪求90 请问购物车的思路? .aspx页面,如何让表单提交后,按IE后退按钮后,文本框清空? 如何实现WEBFORM中的LABEL的单击,双击,N击事件? 用richTextBox保存、显示、打印带图片内容的例子 如何只生成单一实例 Asp.Net 2.0 GridView的问题~~分不够可以再加
=>我已经设置好了,而且还追加了NETWORKSERVECE,还是没有用!谢谢你!还有更好的解决方法吗?
=>不是本地的任意一个共享文件夹下面没有写文件的权限,你需要配置ASP.NET用户在文件目录有写的系统权限
=〉已经设置过了,可能没有设全谢谢大家
这样设置权限:
找到你要操纵的文件
右击-安全-groups and user names(Users打钩)-permissions for users 里面得(full Control打钩)
或是你打开没有关闭,或是写的同时有程序在读
// strTempFilePath = @"\\服务器具体地址"
using (StreamWriter sw = new StreamWriter(strTempFilePath, false, Encoding.GetEncoding("shift-jis")))
{
sw.Write(strFileContent);
}
1,添加一个用户Demo密码Demo,并将这个用户加入到administrators组。
2,在web.config下如下设置
<configuration>
<system.web>
<identity userName="Demo" password="Demo">
</identity>
</system.web>
</configuration>
模拟一个有管理员权限的用户。
1,添加一个用户Demo密码Demo,并将这个用户加入到administrators组。
2,在web.config下如下设置
<configuration>
<system.web>
<identity userName="Demo" password="Demo">
</identity>
</system.web>
</configuration>
=>这个可能是一种解决方法,我过会儿试一下。我后来调cmd.exe用net use映射的方法拷过去,也用到了用户名和密码,而且这样是成功了的。
string strFilePath = SystemConfig.GetStringValue("C06", "FilePath");
//从初始化文件中读取上传机器的UserName
string strUserName = SystemConfig.GetStringValue("C06", "UserName");
//从初始化文件中读取上传机器的密码
string strPassword = SystemConfig.GetStringValue("C06", "Password");
//文件名
strFileName += DateTime.Now.ToString("yyyyMMddHHmmss") + ".csv";
//零时文件名
string strTempFilePath = string.Format(@"C:\{0}", strFileName);using (StreamWriter sw = new StreamWriter(strTempFilePath, false, Encoding.GetEncoding("shift-jis")))
{
sw.Write(strFileContent);
}string myCommon = string.Format(@"copy C:\{0} U:\{1}", strFileName, strFileName);Process process=new Process();
process.StartInfo.FileName="cmd.exe";
process.StartInfo.UseShellExecute=false;
process.StartInfo.RedirectStandardInput = true;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.RedirectStandardError = true;
process.StartInfo.CreateNoWindow = true;process.Start();
process.StandardInput.WriteLine(string.Format(@"net use U: {0} {1} /user:{2}", strFilePath, strPassword, strUserName));
process.StandardInput.WriteLine(myCommon);
process.StandardInput.WriteLine("exit");string myResult = process.StandardOutput.ReadToEnd();
process.Close();if (File.Exists(strTempFilePath))
{
File.Delete(strTempFilePath);
}
=>我感觉我的权限已经设了够大了,你能不能具体说一下怎么设?而且我已经把ASP.NET 和NETWORK SERVICE 都已经加了,都是同样的错啊!