Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to create file on server with special privileges on Asp .net using visual basic?
    primarykey
    data
    text
    <p>One of the client requirements is that the server generate files and store them on a special folder. This files created can not be modified by users or deleted. So the only way I thought is to generate this files with elevated privileges so a normal user can't delete or modify them. But the question is how can I generate a file with this privileges that normal users can interact with this files... only download from server.</p> <p>I use this code to generate the file... But I don't know how to configure it for elevated privileges.</p> <p>This is the button which generate the file and allow to download it:</p> <pre><code>Protected Sub ibtGenerar_OnClick(ByVal sender As Object, ByVal e As ImageClickEventArgs) oArchivoTelecredito.NombreArchivo = txtNombreArchivo.Text oArchivoTelecredito.SesionDetalleArchivosTelecredito = New List(Of DetalleArchivoTelecreditoBE) Dim oArchivoTelecreditoSL As New ArchivoTelecreditoSL Response.AddHeader("Content-disposition", "attachment;filename=" &amp; oArchivoTelecredito.NombreArchivo &amp; ".txt") Response.ContentType = "application/octet-stream" Response.BinaryWrite(oArchivoTelecreditoSL.GeneraArchivoTelecredito(oArchivoTelecredito, Server.MapPath(oArchivoTelecredito.NombreArchivo))) Response.End() End Sub </code></pre> <p>This is the function which create the file on server:</p> <pre><code>Public Function GeneraArchivoTelecredito(ByVal telecredito As ArchivoTelecreditoBE, ByVal ruta As String) As Byte() Dim lineas As Integer = telecredito.SesionDetalleArchivosTelecredito.Count + 1 Dim registro(0 To lineas) As String registro(0) = Me.ObtenerCabeceraArchivoTelecredito(telecredito) Dim archivo = ruta &amp; ".txt" Using escritor As New StreamWriter(archivo) For index = 0 To lineas escritor.WriteLine(registro(index)) Next escritor.Close() End Using Dim lector As FileStream lector = File.Open(archivo, FileMode.Open) Dim bytes(lector.Length) As Byte lector.Read(bytes, 0, lector.Length) lector.Close() Return bytes End Function </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload