请教大家,用StreamWriter写文件时,“访问被拒绝” ,我的系统是2003的,这个是怎么回事?怎么才能成功?谢谢了!

解决方案 »

  1.   

    权限问题,设置读写文件夹的权限~!
    =>我已经设置好了,而且还追加了NETWORKSERVECE,还是没有用!谢谢你!还有更好的解决方法吗?
      

  2.   

    没有写文件的权限,你需要配置ASP.NET用户在文件目录有写的系统权限
      

  3.   

    哪个路径下的?说详细一些.
    =>不是本地的任意一个共享文件夹下面没有写文件的权限,你需要配置ASP.NET用户在文件目录有写的系统权限
    =〉已经设置过了,可能没有设全谢谢大家
      

  4.   

    你怎么设置得权限?》确保你设置了写权限麽?
    这样设置权限:
    找到你要操纵的文件
    右击-安全-groups and user names(Users打钩)-permissions for users 里面得(full Control打钩)
      

  5.   

    一般说来是权限问题,添加everyone等的修改权限,
    或是你打开没有关闭,或是写的同时有程序在读
      

  6.   

    添加everyone这个用户到这个文件和文件夹的安全标签里!权限设置完全!在试试看
      

  7.   

    // strFileContent 要写的字符串
    // strTempFilePath = @"\\服务器具体地址"
    using (StreamWriter sw = new StreamWriter(strTempFilePath, false, Encoding.GetEncoding("shift-jis")))
    {
    sw.Write(strFileContent);
    }
      

  8.   

    和远程服务器的设置有没有关系呢?应该还是权限的问题,如果就是本机的话,你看看.net安装后几个比如DEBUGUSER之类的帐户的权限
      

  9.   

    这是因为windows2003系统的安全性设置问题,系统把EveryOne用户经干掉了,你可以在网上找一下这权限修改问题。
      

  10.   

    asp.net 也是一个用户,要把它加进去.
      

  11.   

    模拟一个有管理员权限的用户。
    1,添加一个用户Demo密码Demo,并将这个用户加入到administrators组。
    2,在web.config下如下设置
    <configuration>
       <system.web>
          <identity userName="Demo" password="Demo"> 
           </identity>
       </system.web>
    </configuration>
      

  12.   

    回复人: 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映射的方法拷过去,也用到了用户名和密码,而且这样是成功了的。
      

  13.   

    //从初始化文件中读取上传文件的路径
    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);
    }
      

  14.   

    设置写权限
    =>我感觉我的权限已经设了够大了,你能不能具体说一下怎么设?而且我已经把ASP.NET 和NETWORK SERVICE 都已经加了,都是同样的错啊!