如何使用vb在asp.net的Program Files文件夹中创建包含内容的文件 [英] How to create file with content in Program Files folder in asp.net using vb

查看:82
本文介绍了如何使用vb在asp.net的Program Files文件夹中创建包含内容的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我正在创建一个包含以下代码的内容的dll文件,我指定C:\Program Files \ baidu的路径,我将Everyone权限授予baidu文件夹内的 C:\Program Files



Hi I am creating one dll file with content with following code,i specify the path to "C:\Program Files\baidu",i give "Everyone" permission to "baidu" folder inside "C:\Program Files"

Protected Sub Button1_Click(sender As Object, e As System.EventArgs) Handles Button1.Click
      Try
        Dim workingdir As String = "C:\Program Files (x86)\baidu"

      Dim strContent As String = "ABCDEFGHIJKLMNOPQURSTUVWXYZ"
       Dim viewPath As String = workingdir & "\LIC "
          Try
              If Not Directory.Exists(viewPath) Then
                  Directory.CreateDirectory(viewPath)
              End If
          Catch ex As Exception

           End Try

          Dim keyFile As String = viewPath + "\ASSBOALIC.dll"
          Dim outFile As IO.StreamWriter = My.Computer.FileSystem.OpenTextFileWriter(keyFile, False)
          outFile.WriteLine(strContent)
          outFile.Close()
          outFile.Dispose()
          ShowMessage("success")
      Catch ex As Exception
          ShowMessage(ex.Message.ToString)
      End Try
  End Sub







以上代码适用于我的机器和大多数服务器,但有些服务器它无法创建dll文件,它显示错误像C:\Program Files \baidu访问被拒绝,甚至我给大家,ASP.Net用户,IUSER,管理员,完全控制的用户



所以如何在获得许可的情况下创建dll文件。 />




问候

Aravind




The above code works in my machine and most of the server,but some server it cant create dll file ,it show error like "C:\Program Files\baidu Access to denied",Even i gave everyone,ASP.Net user,IUSER,Administrator,Users with Full Control

so how to create dll file with permission.


Regards
Aravind

推荐答案

你必须仔细检查哪个帐户正在运行你的ASP.NET代码运行的应用程序池。



然后你必须仔细检查你的文件夹的权限我正试着写进去。



说真的,别无选择。运行代码的帐户具有在该文件夹中写入的权限,或者您的代码会抛出拒绝访问。没有解决这个问题。



除此之外,你所做的事情没有任何意义。 .DLL文件应该是可执行代码,您将文件视为文本文件。您不能将可执行代码编写为Text并期望它可以工作。
You have to double-check which account is running the app pool your ASP.NET code is running under.

Then you have to double-check the permissions on the folder you're trying to write in.

Seriously, there is no other option. The account running your code either has the permissions to write in that folder or your code throws Access Denied. There is no getting around that.

On top of that, what you're doing doesn't make any sense. A .DLL file is expected to be executable code and you're treating the file as a text file. You cannot write executable code as Text and expect it to work.


这篇关于如何使用vb在asp.net的Program Files文件夹中创建包含内容的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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