Results 1 to 2 of 2

Thread: writing to registry with a assembly

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2002
    Posts
    13

    writing to registry with a assembly

    hi@all!

    I have a component (assembly) with an object that writes data to a registry key.

    When this is run from a Windows app, it works like a charm. When run from a web app, it doesnt work.

    here is the code:

    Code:
      Public Function sendandprint(ByVal path As String)
    
          Dim Key As Microsoft.Win32.RegistryKey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("Software\pdfMachine\BroadGun pdfMachine", True)
            Dim f As New RegistryPermission(RegistryPermissionAccess.AllAccess, Key.Name)
            f.Assert()
    
    
            Dim success As Integer
            Dim strfile As String
            Dim strpath As String
            Dim pdffile As String
    
            Dim reader As StreamReader = New StreamReader(path + "pdfpath.txt")
            pdffile = reader.ReadLine
            reader.Close()
    
            Try
                If Not IsNothing(Key) Then
                    Key.SetValue("DefaultSaveDir", path)
                    Key.SetValue("DefaultSaveFilename", pdffile)
                    strfile = Key.GetValue("DefaultSaveFilename")
                    strpath = Key.GetValue("DefaultSaveDir")
                    Key.Close()
                    Dim fs4 As New FileStream(path & "print.txt", FileMode.Append)
                    Dim sw4 As New StreamWriter(fs4)
                    sw4.WriteLine("done")
                    sw4.Close()
    
                Else
                    Dim fs4 As New FileStream(path & "print.txt", FileMode.Append)
                    Dim sw4 As New StreamWriter(fs4)
                    sw4.WriteLine("is nothing")
                    sw4.Close()
                End If
            Catch ex As Exception
                Dim fs4 As New FileStream(path & "print.txt", FileMode.Append)
                Dim sw4 As New StreamWriter(fs4)
                sw4.WriteLine(ex.Message + " Fehler beim Schreiben")
                sw4.Close()
            End Try
    
    End Function
    thx for any suggestions u have!

    greetings
    Last edited by PJ6; Nov 4th, 2003 at 10:44 AM.

  2. #2
    Frenzied Member MrGTI's Avatar
    Join Date
    Oct 2000
    Location
    Ontario, Canada
    Posts
    1,277

    Arrow

    Most likely the web user does not have the rights to do that.

    Try asking this question in the ASP.NET forum - It doesn't make sense to ask it here.
    ~Peter


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width