hola a todos, estoy creando un archivo .txt en con el siguiente codigo:
Dim strStreamWriter As StreamWriter
Dim strStreamW As Stream
Dim FilePath As String = "Archivo.txt"
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim filename As String = Server.MapPath("~/mensaje/errores/" + FilePath)
strStreamW = File.OpenWrite(filename)
strStreamWriter = New StreamWriter(strStreamW, System.Text.Encoding.UTF8)
strStreamWriter.Close()
strStreamW.Close()
pero me sale el siguiente error cuando lo ejecuto:
Server Error in '/pca_z' Application.
--------------------------------------------------------------------------------
The process cannot access the file 'c:\inetpub\wwwroot\xyz\mensaje\errores\Archivo.tx t' because it is being used by another process.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.IO.IOException: The process cannot access the file 'c:\inetpub\wwwroot\xyz\mensaje\errores\Archivo.tx t' because it is being used by another process.
Source Error:
Line 21: Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Line 22: Dim filename As String = Server.MapPath("~/_administracion/deudas/errores/" + FilePath)
Line 23: strStreamW = File.OpenWrite(filename)
Line 24: strStreamWriter = New StreamWriter(strStreamW, System.Text.Encoding.UTF8)
Line 25:
alguna idea de como solucionar este problema?
se lo agradeceria mucho!