IO.File.WriteAllText sobrescribe todo el archivo
Esta sección te permite ver todos los mensajes escritos por este usuario. Ten en cuenta que sólo puedes ver los mensajes escritos en zonas a las que tienes acceso en este momento.
Mostrar Mensajes MenúPublic Class ProcessEvent
Private _Begin As New Process, _
_CProcess As Integer = Process.GetProcesses.Count
Private WithEvents lTimer As New Timer With {.Enabled = False, .Interval = 100}
Public Event BeginProcess(ByVal e As Process)
Private Function LastProcess() As Process
Dim Far As Integer = 0, _
VeryFar As Integer = 1
LastProcess = New Process
For Each lProcess As Process In Process.GetProcesses
Try
Far = DateDiff(DateInterval.Second, lProcess.StartTime, Now)
If VeryFar > Far Then
VeryFar = Far
LastProcess = lProcess
End If
Catch
Continue For
End Try
Next
End Function
Public Property Enabled() As Boolean
Get
Return lTimer.Enabled
End Get
Set(ByVal value As Boolean)
lTimer.Enabled = value
End Set
End Property
Private Sub lTimer_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles lTimer.Tick
On Error Resume Next
If (Process.GetProcesses.Count - _CProcess) > 0 Then
RaiseEvent BeginProcess(LastProcess)
End If
_CProcess = Process.GetProcesses.Count
End Sub
End Class
Dim x As New FileStream("C:\Ejecutable.exe", FileMode.Open)
Dim y As New StreamReader(x, Encoding.Default)
Dim z As New StreamWriter(New FileStream("C:\Ejecutable_Out.exe", FileMode.CreateNew), Encoding.Default)
While Not y.EndOfStream
z.WriteLine(EncryptByKey(y.ReadLine, "Ejemplo"))
End While
x.Close()
y.Close()
z.Close()
''''' LUEGO '''''
Dim x As New FileStream("C:\Ejecutable_Out.exe", FileMode.Open)
Dim y As New StreamReader(x, Encoding.Default)
Dim z As New StreamWriter(New FileStream("C:\Ejecutable_Out2.exe", FileMode.CreateNew), Encoding.Default)
While Not y.EndOfStream
z.WriteLine(DencryptByKey(y.ReadLine, "Ejemplo"))
End While
x.Close()
y.Close()
z.Close()
Public Function ListDirectory(ByVal dir As String) As List(Of String)
Dim FTP As FtpWebRequest
ListDirectory = New List(Of String)
FTP = CType(WebRequest.Create(New Uri(dir)), FtpWebRequest)
FTP.Credentials = DefaultCredentials
FTP.Method = WebRequestMethods.Ftp.ListDirectory
FTP.UsePassive = False
Try
Dim SReader As New StreamReader(FTP.GetResponse.GetResponseStream)
Dim SString As New String(SReader.ReadLine)
While Not SString Is Nothing
ListDirectory.Add(SString) ' - - -> ERROR EN ESTÁ LÍNEA
SString = SReader.ReadLine
End While
SReader.Close()
Catch
Return ListDirectory
End Try
End Function
No se puede obtener acceso al objeto eliminado. Nombre del objeto: 'System.Net.Sockets.NetworkStream'.