elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: (TUTORIAL) Aprende a emular Sentinel Dongle By Yapis


  Mostrar Mensajes
Páginas: [1] 2
1  Programación / .NET (C#, VB.NET, ASP) / Re: Mostrar barra de progreso al copiar un archivo. en: 6 Agosto 2018, 11:53 am
Creo que tienes razón, cierro el hilo. Gracias.
2  Programación / .NET (C#, VB.NET, ASP) / Re: Mostrar barra de progreso al copiar un archivo. en: 6 Agosto 2018, 01:13 am
Osea algo asi?

Código
  1.        My.Computer.FileSystem.CopyFile(ListBox1, ListBox2, FileIO.UIOption.AllDialogs)
  2.  

Me sigue dando error... en copyfile
3  Programación / .NET (C#, VB.NET, ASP) / Re: Mostrar barra de progreso al copiar un archivo. en: 6 Agosto 2018, 00:36 am
Lo que quiero es copiar el archivo que seleccione no el directorio.

Código
  1. Dim sourceFileName As String
  2. Dim destinationFileName As String

No se como decirle que archivo si siempre sera diferente?
4  Programación / .NET (C#, VB.NET, ASP) / Mostrar barra de progreso al copiar un archivo. en: 5 Agosto 2018, 23:25 pm
Hola, al intentar copiar un archivo y que me muestre la barra de progreso por defecto de windows me esta dando un error y ya no veo porque.

Código
  1.  
  2.        Dim srcFile1 As String
  3.        Dim dstFile1 As String
  4.  
  5.        srcFile1 = "C:\Users\Alfredo\Desktop\iconos1"
  6.        dstFile1 = "C:\Users\Alfredo\Desktop\iconos2"
  7.  
  8.        My.Computer.FileSystem.CopyFile(srcFile1, dstFile1, FileIO.UIOption.AllDialogs)

Este es el codigo y este el error que me da.

System.IO.FileNotFoundException: 'No se pudo encontrar el archivo 'C:\Users\Alfredo\Desktop\iconos1'.'

Sabeis que me falta?

gracias-
5  Programación / .NET (C#, VB.NET, ASP) / Re: VB Copiar archivos de una carpeta (listbox1 y 2) cambiando nombre desde un textb en: 7 Julio 2018, 21:32 pm
He cambiado estas opciones.

Código
  1.        Try ' Movemos el archivo de origen a la ruta de destino.
  2.            srcFile.CopyTo(dstFile.FullName) ' move cambiado por copy
  3.  
  4.        Catch ex As Exception
  5.            Throw
  6.  
  7.        End Try
  8.  
  9.        ' Actualizamos las colecciones de archivos.
  10.        'Me.SrcCollection.Remove(srcFile) Este lo he quitado
  11.        Me.DstCollection.Add(dstFile)

Aqui pongo el filtro

Código
  1.        Dim srcFiles As IEnumerable(Of FileInfo) = New DirectoryInfo(Me.srcFolderPath).EnumerateFiles("*.mp4", SearchOption.TopDirectoryOnly)
  2.        Dim dstFiles As IEnumerable(Of FileInfo) = New DirectoryInfo(Me.dstFolderPath).EnumerateFiles("*.mp4", SearchOption.TopDirectoryOnly)

Ahora ya filtra y copia, esta bien asi?

El watcher creo que no funciona, estoy moviendolo a ver si doy con la tecla, solo me falta eso.




Elimino el watcher, la verdad es que no me hace falta.
He quitado todo lo que me dijiste y ha quedado mas limpio.

Gracias.

[MOD] para añadir comentarios usar el botón "modificar". No está permitido el doble post. Perdona no lo sabia.

Al final el watcher si que lo usare, voy a ver.
Gracias y perdona
6  Programación / .NET (C#, VB.NET, ASP) / Re: VB Copiar archivos de una carpeta (listbox1 y 2) cambiando nombre desde un textb en: 7 Julio 2018, 21:07 pm
Hola!

estoy viendo lo que me comentaste, esta parte no la entiendo muy bien.

    Private Sub NOMBRE_DEL_METODO()

Nombre del método? podría poner cualquier nombre?

Muchas gracias por la ayuda, voy a ver si me aclaro.
7  Programación / .NET (C#, VB.NET, ASP) / Re: VB Copiar archivos de una carpeta (listbox1 y 2) cambiando nombre desde un textb en: 4 Julio 2018, 16:51 pm
Código
  1.        Me.ListBox1.Sorted = True
  2.        Me.ListBox1.DisplayMember = "Name"
  3.        Me.ListBox1.DataSource = Me.SrcCollection
  4.  
  5.        Me.ListBox2.Sorted = True
  6.        Me.ListBox2.DisplayMember = "Name"
  7.        Me.ListBox2.DataSource = Me.DstCollection
  8.  
  9.    End Sub
  10.  
  11.  
  12.  
  13.  
  14.    Dim directory2 = "C:\Users\Alfredo\Desktop\iconos2"
  15.        Dim files2() As System.IO.FileInfo
  16.        Dim dirinfo2 As New System.IO.DirectoryInfo(directory2)
  17.        files2 = dirinfo2.GetFiles("*.mp4", IO.SearchOption.AllDirectories) ' DECIRLE QUE EXTENSION DE ARCHIVO ´AQUI MI CODIGO COMIENZA  A DAR FALLOS.
  18.        For Each file In files2    ´AQUI MI CODIGO COMIENZA  A DAR FALLOS.
  19.            ListBox2.Items.Add(file)   ´AQUI MI CODIGO COMIENZA  A DAR FALLOS.
  20.  
  21.        Next
  22.  
  23.        ''''''''''''''''' NECESARIO PARA VIGILAR LOS ARCHIVOSDE UNA CARPETA
  24.        Me.CheckForIllegalCrossThreadCalls = False         ´AQUI MI CODIGO COMIENZA  A DAR FALLOS.
  25.  
  26.        fswc = New FileSystemWatcher("C:\Users\Alfredo\Desktop\iconos")    ´AQUI MI CODIGO COMIENZA  A DAR FALLOS.
  27.        fswc.IncludeSubdirectories = False    ´AQUI MI CODIGO COMIENZA  A DAR FALLOS.
  28.        fswc.EnableRaisingEvents = True      ´AQUI MI CODIGO COMIENZA  A DAR FALLOS.
  29.        '---------------------------------------
  30.  
  31.        'muestra contenido carpeta'
  32.  
  33.        Dim directory = "C:\Users\Alfredo\Desktop\iconos"
  34.        Dim files() As System.IO.FileInfo
  35.        Dim dirinfo As New System.IO.DirectoryInfo(directory)
  36.        files = dirinfo.GetFiles("*.mp4", IO.SearchOption.AllDirectories) ' DECIRLE QUE EXTENSION DE ARCHIVO    ´AQUI MI CODIGO COMIENZA  A DAR FALLOS.
  37.        For Each file In files                            ´AQUI MI CODIGO COMIENZA  A DAR FALLOS.
  38.            ListBox1.Items.Add(file)                    ´AQUI MI CODIGO COMIENZA  A DAR FALLOS.
  39.  
  40.        Next
  41.  
  42.  
  43.  
  44.    End Sub
  45.  
  46.  
  47.  
8  Programación / .NET (C#, VB.NET, ASP) / Re: VB Copiar archivos de una carpeta (listbox1 y 2) cambiando nombre desde un textb en: 4 Julio 2018, 16:35 pm
Perdona, tienes razon, he ido demasiado rapido y al final no se ni lo que pongo ni el como.... La verdad es que estoy "rallado" y me da la impresión de que en vez de hacer estoy deshaciendo.... Pero bueno.

Te lo pongo en varios que no me coje mas de 100 lineas creo.
Código
  1.  
  2. Imports System
  3. Imports System.IO
  4.  
  5. Public Class Form2
  6.  
  7.    Private srcFolderPath As String = "C:\Users\morygor\Desktop\iconos1" ' Directorio de origen
  8.    Private cdstFolderPath As String = "C:\Users\morygor\Desktop\iconos2" ' Directorio de destino
  9.  
  10.    Private WithEvents SrcCollection As [i]ObservableCollection(Of FileInfo)[/i] ' Colección de archivos del directorio de origen   ´ESTO QUE ESTA ENTRE LA I , NO ESTA DEFINIDO EL TIPO ObservableCollection
  11.    Private WithEvents DstCollection As [i]ObservableCollection(Of FileInfo)[/i]' Colección de archivos del directorio de destino    ´ESTO QUE ESTA ENTRE LA I , NO ESTA DEFINIDO EL TIPO ObservableCollection
  12.  
  13.    ' Obtiene el nuevo nombre que será asignado al archivo de origen al moverlo al directorio de destino...
  14.  
  15.    Private ReadOnly Property NewFilename As String
  16.        Get
  17.            Return Me.TextBox4.Text.Trim()
  18.        End Get
  19.    End Property
  20.    '-------------------NECESARIO PARA VIGILAR LOS ARCHIVOSDE UNA CARPETA
  21.    Public WithEvents fswc As FileSystemWatcher
  22.  
  23.    '------------------- MOVER EL FORMULARIO
  24.    <DllImport("user32.DLL", EntryPoint:="ReleaseCapture")>
  25.    Private Shared Sub ReleaseCapture()
  26.    End Sub
  27.  
  28.    <DllImport("user32.DLL", EntryPoint:="SendMessage")>
  29.    Private Shared Sub SendMessage(ByVal hWnd As System.IntPtr, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As Integer)
  30.    End Sub
  31.  
  32.    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
  33.        Me.Close() 'orden para cerrar'
  34.  
  35.    End Sub
  36.  
  37.    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
  38.        Me.WindowState = FormWindowState.Minimized 'orden para minimizar'
  39.  
  40.    End Sub
  41.  
  42.    Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  43.  
  44.        ' Construimos las colecciones de archivos del directorio de origen y destino,
  45.        ' y enlazamos dichas colecciones a los ListBoxes...
  46.  
  47.        Dim srcFiles As IEnumerable(Of FileInfo) = [i]New DirectoryInfo(Me.srcFolderPath).EnumerateFiles[/i]("*", SearchOption.TopDirectoryOnly)      ---- pone que no es un miembro de directoryinfo
  48.  
  49.        Dim dstFiles As IEnumerable(Of FileInfo) = New DirectoryInfo[color=green][i](Me.dstFolderPath)[/i][/color].EnumerateFiles("*", SearchOption.TopDirectoryOnly) ' NO es un miembro de form2
  50.  
  51.        Me.SrcCollection = NeW [i]ObservableCollection(Of FileInfo)[/i](srcFiles)' NO ESTA DEFINIDO ObservableCollection
  52.  
  53.        Me.DstCollection = New [i]ObservableCollection(Of FileInfo)[/i](dstFiles)' NO ESTA DEFINIDO ObservableCollection
  54.  
  55.  
9  Programación / .NET (C#, VB.NET, ASP) / Re: VB Copiar archivos de una carpeta (listbox1 y 2) cambiando nombre desde un textb en: 4 Julio 2018, 15:57 pm
Hola, alguna cosa no encaja, me salen bastantes fallos.
Esto es lo que tengo en este form.


Imports System.Runtime.InteropServices
Imports System
Imports System.IO

Public Class Form2
    '-------------------NECESARIO PARA VIGILAR LOS ARCHIVOSDE UNA CARPETA
    Public WithEvents fswc As FileSystemWatcher

    '------------------- MOVER EL FORMULARIO
    <DllImport("user32.DLL", EntryPoint:="ReleaseCapture")>
    Private Shared Sub ReleaseCapture()
    End Sub

    <DllImport("user32.DLL", EntryPoint:="SendMessage")>
    Private Shared Sub SendMessage(ByVal hWnd As System.IntPtr, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As Integer)
    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Me.Close() 'orden para cerrar'

    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        Me.WindowState = FormWindowState.Minimized 'orden para minimizar'

    End Sub

    Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Dim directory2 = "C:\Users\mortigor\Desktop\iconos2"
        Dim files2() As System.IO.FileInfo
        Dim dirinfo2 As New System.IO.DirectoryInfo(directory2)
        files2 = dirinfo2.GetFiles("*.mp4", IO.SearchOption.AllDirectories) ' DECIRLE QUE EXTENSION DE ARCHIVO
        For Each file In files2
            ListBox2.Items.Add(file)

        Next

        ''''''''''''''''' NECESARIO PARA VIGILAR LOS ARCHIVOSDE UNA CARPETA
        Me.CheckForIllegalCrossThreadCalls = False

        fswc = New FileSystemWatcher("C:\Users\Alfredo\Desktop\iconos")
        fswc.IncludeSubdirectories = False
        fswc.EnableRaisingEvents = True
        '---------------------------------------

        'muestra contenido carpeta'

        Dim directory = "C:\Users\mortigor\Desktop\iconos"
        Dim files() As System.IO.FileInfo
        Dim dirinfo As New System.IO.DirectoryInfo(directory)
        files = dirinfo.GetFiles("*.mp4", IO.SearchOption.AllDirectories) ' DECIRLE QUE EXTENSION DE ARCHIVO
        For Each file In files
            ListBox1.Items.Add(file)

        Next



    End Sub



    Private Sub Panel1_MouseMove(sender As Object, e As MouseEventArgs) Handles Panel1.MouseMove
        ReleaseCapture()
        SendMessage(Me.Handle, &H112&, &HF012&, 0)
    End Sub

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

    End Sub


    Private Sub fswc_Changed(sender As Object, e As FileSystemEventArgs) Handles fswc.Changed
        ListBox1.Items.Clear()
        Dim directory = "C:\Users\mortigor\Desktop\iconos"
        Dim files() As System.IO.FileInfo
        Dim dirinfo As New System.IO.DirectoryInfo(directory)
        files = dirinfo.GetFiles("*.mp4", IO.SearchOption.AllDirectories) ' DECIRLE QUE EXTENSION DE ARCHIVO
        For Each file In files
            ListBox1.Items.Add(file)

        Next
    End Sub

    Private Sub fswc_Created(sender As Object, e As FileSystemEventArgs) Handles fswc.Created
        ListBox1.Items.Clear()
        Dim directory = "C:\Users\mortigor\Desktop\iconos"
        Dim files() As System.IO.FileInfo
        Dim dirinfo As New System.IO.DirectoryInfo(directory)
        files = dirinfo.GetFiles("*.mp4", IO.SearchOption.AllDirectories) ' DECIRLE QUE EXTENSION DE ARCHIVO
        For Each file In files
            ListBox1.Items.Add(file)

        Next
    End Sub

    Private Sub fswc_Deleted(sender As Object, e As FileSystemEventArgs) Handles fswc.Deleted
        ListBox1.Items.Clear()
        Dim directory = "C:\Users\mortigor\Desktop\iconos"
        Dim files() As System.IO.FileInfo
        Dim dirinfo As New System.IO.DirectoryInfo(directory)
        files = dirinfo.GetFiles("*.mp4", IO.SearchOption.AllDirectories) ' DECIRLE QUE EXTENSION DE ARCHIVO
        For Each file In files
            ListBox1.Items.Add(file)

        Next
    End Sub

    Private Sub fswc_Disposed(sender As Object, e As EventArgs) Handles fswc.Disposed
        ListBox1.Items.Clear()
    End Sub

    Private Sub fswc_Error(sender As Object, e As ErrorEventArgs) Handles fswc.[Error]
        ListBox1.Items.Clear()
    End Sub

    Private Sub fswc_Renamed(sender As Object, e As RenamedEventArgs) Handles fswc.Renamed
        ListBox1.Items.Clear()
        Dim directory = "C:\Users\mortigor\Desktop\iconos"
        Dim files() As System.IO.FileInfo
        Dim dirinfo As New System.IO.DirectoryInfo(directory)
        files = dirinfo.GetFiles("*.mp4", IO.SearchOption.AllDirectories) ' DECIRLE QUE EXTENSION DE ARCHIVO
        For Each file In files
            ListBox1.Items.Add(file)

        Next
    End Sub

    Private Sub ListBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ListBox1.SelectedIndexChanged




    End Sub
    Private Sub Label2_Click(sender As Object, e As EventArgs) Handles Label2.Click

    End Sub

    Private Sub Label3_Click(sender As Object, e As EventArgs) Handles Label3.Click

    End Sub

    Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click

    End Sub

    Private Sub TextBox4_TextChanged(sender As Object, e As EventArgs) Handles TextBox4.TextChanged

    End Sub

    Private Sub ListBox2_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ListBox2.SelectedIndexChanged

    End Sub

    Private Sub BackgroundWorker1_DoWork(sender As Object, e As ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork

    End Sub

Esto es lo que tengo por ahora, me lee el archivo el listbox, tengo un watcher para que me lo actualice cada vez que hay algún cambio.

Tengo 2 listbox, button, listbox.

No se como encajarlo..
10  Programación / .NET (C#, VB.NET, ASP) / Re: VB Copiar archivos de una carpeta (listbox1 y 2) cambiando nombre desde un textb en: 3 Julio 2018, 22:24 pm
Hola Elektro, lo primero muchas gracias por contestar, voy a probarlo y te cuento.

Muchas gracias y un saludo.
Páginas: [1] 2
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines