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

 

 


Tema destacado: Guía rápida para descarga de herramientas gratuitas de seguridad y desinfección


  Mostrar Mensajes
Páginas: 1 ... 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 [984] 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 ... 1236
9831  Programación / .NET (C#, VB.NET, ASP) / Re: ¿Cambiar varios atributos a un archivo sin que se remplaze el ultimo cambiado? en: 9 Enero 2013, 21:16 pm
Código
  1. FileSystem.SetAttr("Archivo", IO.FileAttributes.System + IO.FileAttributes.Hidden)

Saludos

EDITO:
Código
  1.    ' Usage:
  2.    ' Attrib("File.txt", IO.FileAttributes.ReadOnly + IO.FileAttributes.System)
  3.  
  4.    Private Function Attrib(ByVal File As String, ByVal Attributes As System.IO.FileAttributes)
  5.        Try
  6.            FileSystem.SetAttr(File, Attributes)
  7.            Return True
  8.        Catch
  9.            Return Nothing
  10.        End Try
  11.    End Function
9832  Programación / Scripting / Re: Contador de ficheros (BATCH) en: 9 Enero 2013, 20:11 pm
Código
  1. @Echo OFF
  2.  
  3. :: By Elektro H@cker
  4.  
  5. Set "TempFile=%SystemDrive%\FileCount.tmp"
  6.  
  7. If NOT Exist "%TempFile%" (fsutil file createnew "%TempFile%" 0 1>NUL)
  8.  
  9. For /F "usebackq" %%X in ("%TempFile%") Do (Set /A Last_Total_Files=%%X)
  10.  
  11. FOR %%@ IN (*.*) DO (Set /A TotalFiles+=1)
  12.  
  13. If NOT defined Last_Total_Files (Set /A Last_Total_Files=0)
  14.  
  15. Set /A NewFiles=TotalFiles-Last_Total_Files
  16.  
  17. <Nul Set /P Total=%TotalFiles% >"%TempFile%"
  18.  
  19. Echo Archivos antes: %Last_Total_Files%
  20. Echo Archivos ahora: %TotalFiles%
  21. Echo Nuevos archivos: %NewFiles%
  22.  
  23. Pause&Exit

 

Saludos
9833  Programación / .NET (C#, VB.NET, ASP) / Re: Buscar todas las variantes de un string en: 9 Enero 2013, 15:56 pm
Gracias, pero no me aclaro, ¿Como puedo adaptarla a mis necesidades?

Tengo una "Search bar" que debe buscar resultados en los archivos de texto de "My.Resources", y mostrar cada resultado encontrado en el listview.
Lo único que quiero es hacer el texto a buscar en modo "Ignorecase" xD




Al pulsar el botón "Buscar":
Código
  1. For Each Dict As DictionaryEntry In ResourceSet.OfType(Of Object)()
  2.            If TypeOf (Dict.Value) Is String Then
  3.                Find_Delimited_Text(My.Resources.ResourceManager.GetObject(Dict.Key), ";", TextBox_Buscar.Text)


Find_Delimited_Text sub:
Código
  1.    Public Sub Find_Delimited_Text(ByVal TextFile As String, ByVal TextDelimiter As String, ByVal PatternSTR As String)
  2.  
  3.        Dim vLetras As String = PatternSTR
  4.        Dim vSize As Integer = PatternSTR.Length  ' ¿?
  5.  
  6.        Dim vLista As IEnumerable(Of String) = vLetras.Select(Function(x) x.ToString())
  7.  
  8.        For i As Integer = 0 To vSize - 2
  9.            vLista = vLista.SelectMany(Function(x) vLetras, Function(x, y) x + y)
  10.        Next
  11.  
  12.        For Each t As String In vLista
  13.            MsgBox(t)
  14.        Next
  15.  
  16.        Dim Listview_Row_STR(4) As String
  17.        Dim Listview_Item = New ListViewItem(Listview_Row_STR)
  18.        Dim TextDelimited As String()
  19.        Dim delimiter As String = TextDelimiter
  20.        Dim fileContent As String = TextFile
  21.  
  22.        Dim stringStream As New System.IO.StringReader(fileContent)
  23.        Using parser As New Microsoft.VisualBasic.FileIO.TextFieldParser(stringStream)
  24.            parser.SetDelimiters(TextDelimiter)
  25.            While Not parser.EndOfData
  26.                TextDelimited = parser.ReadFields()
  27.                If TextDelimited(0).Contains(PatternSTR) Then
  28.                    field_find_number += 1
  29.                    Listview_Row_STR(0) = field_find_number
  30.                    Listview_Row_STR(1) = TextDelimited(0)
  31.                    Listview_Row_STR(2) = TextDelimited(1)
  32.                    Listview_Row_STR(3) = TextDelimited(2)
  33.                    Listview_Item = New ListViewItem(Listview_Row_STR)
  34.                    ListView.Items.Add(Listview_Item)
  35.                End If
  36.            End While
  37.        End Using
  38.    End Sub



EDITO:
Bueno, creo que convirtiendo los dos strings a lowercase da menos vueltas y funciona.

Código
  1. If TextDelimited(0).ToLower.Contains(PatternSTR.ToLower) Then

Saludos!
9834  Programación / .NET (C#, VB.NET, ASP) / [SOLUCIONADO] Buscar todas las variantes de un string en: 9 Enero 2013, 01:10 am
¿Alguien me puede recordar como se hacia esto?

Olvidé que método se usa para esto xD

Código
  1. Dim STR = "abc"
  2. If Cosa.Contains(STR) Then ...
  3.  
  4. ' Quiero que busque todas las variantes:
  5. ' Abc
  6. ' ABc
  7. ' ABC
  8. ' aBC
  9. ' abC
  10. ' etc...
9835  Programación / .NET (C#, VB.NET, ASP) / Re: Obtener todos los recursos de tipo TEXTO de My.Resources en: 8 Enero 2013, 20:22 pm
Perfecto!

^^

Justo ahora mismo habia sacado ese mismo code en StackOverF... e iba a preguntar cual era el correcto "TypeOf" que debía usar, ya me has sacado de dudas xD

Código
  1. Dim ResourceSet As Resources.ResourceSet = My.Resources.ResourceManager.GetResourceSet(Globalization.CultureInfo.CurrentCulture, True, True)
  2.            For Each Dict As DictionaryEntry In ResourceSet.OfType(Of Object)()
  3.                If TypeOf (Dict.Value) Is Drawing.Image Then
  4.                    Debug.WriteLine(Dict.Key) 'outputting resource name
  5.                End If
  6.            Next
9836  Programación / Scripting / Re: ¿Cómo puedo cambiar el ultimo octeto de una IP con un batch? en: 8 Enero 2013, 19:04 pm
Código
  1. @echo off
  2. Title Configuración de IP
  3.  
  4. :: By Elektro H@cker
  5.  
  6. :Menu
  7. Echo Configuraci¢n de IP:      
  8. Echo -------------------        | MORE
  9. Echo: 1 ^> Segmento [192.168.1.X]
  10. Echo: 2 ^> Segmento [192.168.2.X]
  11. Echo: 3 ^> Segmento [192.168.3.X]
  12. Echo: 4 ^> Segmento [192.168.4.X]
  13. Echo: 5 ^> Salir
  14. Echo.                           | MORE
  15.  
  16. choice /C 12345 /M "elige una opci¢n"
  17.  
  18. For %%# in (%ERRORLEVEL%) DO (
  19. If %%# EQU 1 (Set "Segmento=192.168.1.")
  20. If %%# EQU 2 (Set "Segmento=192.168.2.")
  21. If %%# EQU 3 (Set "Segmento=192.168.3.")
  22. If %%# EQU 4 (Set "Segmento=192.168.4.")
  23. If %%# EQU 5 (Exit /B 0)
  24. Call :Set_Digitos
  25. Call :Set_IP
  26. )
  27. GOTO :MENU
  28.  
  29. :Set_Digitos
  30. CLS
  31. Echo Segmento elegijo [%Segmento%XXX] | MORE
  32. Set /P "Ultimo=Escriba el ultimo bloque de digitos >>"
  33. If "%Ultimo%" EQU "" (GOTO :Set_Digitos)
  34. Echo "%Ultimo%"|Findstr "^\"[0-9]*\"$" && GOTO:EOF || (GOTO :Set_Digitos)
  35.  
  36. :Set_IP
  37. Echo Configurando IP [%Segmento%%ultimo%] | MORE
  38. netsh interface ip set address name="Conexi¢n de  rea local" static %Segmento%%ultimo% 255.255.255.0 %Segmento%1
  39. netsh interface ip set dns name="Conexi¢n de  rea local" static 8.8.8.8
  40. netsh interface ip add dns name="Conexi¢n de  rea local" 8.8.4.4 index=2
  41. GOTO:EOF

Saludos
9837  Programación / .NET (C#, VB.NET, ASP) / Re: Listview, ¿ordenar el contenido al clickar sobre una columna? en: 8 Enero 2013, 18:28 pm
si lo necesitas urgente, avisame y por teamviewver se te enseña rapido, dificil no es XD

Gracias spiritdead pero no me urge, aún estoy aprendiendo a usar el listview convencional.



@seba123Neo

¿Como lo hago funcionar?

Me da error en las variables:
Código:
 vColumnaOrden
    vOrden
Dicen que no están declaradas, y no se con que tipo de valor debo setearlas ni nada xD

Código
  1.  Private Sub GListView_ColumnClick(ByVal sender As Object, ByVal e As System.Windows.Forms.ColumnClickEventArgs) Handles GListView.ColumnClick
  2.  
  3.        Dim vIndiceColumna As ColumnHeader = GListView.Columns(e.Column)
  4.  
  5.        Dim vTipoOrden As System.Windows.Forms.SortOrder
  6.  
  7.        If vColumnaOrden Is Nothing Then
  8.            vTipoOrden = SortOrder.Ascending
  9.            vOrden = SortOrder.Ascending
  10.        Else
  11.            If vIndiceColumna.Equals(vColumnaOrden) Then
  12.                If vOrden = SortOrder.Ascending Then
  13.                    vTipoOrden = SortOrder.Descending
  14.                    vOrden = SortOrder.Descending
  15.                Else
  16.                    vTipoOrden = SortOrder.Ascending
  17.                    vOrden = SortOrder.Ascending
  18.                End If
  19.            Else
  20.                vTipoOrden = SortOrder.Ascending
  21.                vOrden = SortOrder.Ascending
  22.            End If
  23.        End If
  24.  
  25.        vColumnaOrden = vIndiceColumna
  26.  
  27.        GListView.ListViewItemSorter = New COrdenarListview(e.Column, vTipoOrden)
  28.        GListView.Sort()
  29.    End Sub



EDITO:
Seba123Neo, si no he captado mal la idea, al final lo he hecho así, y funciona bien, pero no sé si es peor que tu snippet:



Código
  1.  
  2. ' En las declaraciones...
  3. Dim ColumnOrder As String = "Down"
  4.  
  5.  
  6. Private Sub GListView_ColumnClick(ByVal sender As Object, ByVal e As System.Windows.Forms.ColumnClickEventArgs) Handles GListView.ColumnClick
  7.        If ColumnOrder = "Down" Then
  8.            Me.GListView.ListViewItemSorter = New COrdenarListview(e.Column, SortOrder.Ascending)
  9.            GListView.Sort()
  10.            ColumnOrder = "Up"
  11.        ElseIf ColumnOrder = "Up" Then
  12.            Me.GListView.ListViewItemSorter = New COrdenarListview(e.Column, SortOrder.Descending)
  13.            GListView.Sort()
  14.            ColumnOrder = "Down"
  15.        End If
  16.    End Sub
9838  Programación / .NET (C#, VB.NET, ASP) / Re: No me deja emparentar el form (Form.parent =) en: 8 Enero 2013, 17:34 pm
Ya lo he conseguido, os dejo la solución (Vivan los snippets xD):


Main form:

Código
  1.    Private Sub OnMouseHover(sender As Object, e As EventArgs) Handles Button1.MouseHover
  2.        Form2.Show()
  3.    End Sub
  4.  
  5.    Private Sub OnMouseLeave(sender As Object, e As EventArgs) Handles Button1.MouseLeave
  6.        ' Hay que liberarlo, con un form2.close o form2.hide solo conseguiremos que se centre la primera vez!
  7.        Form2.Dispose()
  8.    End Sub
  9.  
  10. #Region " CenterForm function "
  11.  
  12.    Function centerForm(ByVal Form_to_Center As Form, ByVal Form_Location As Point) As Point
  13.        Dim pLocation As New Point
  14.        pLocation.X = (Me.Left + (Me.Width - Form_to_Center.Width) / 2) '// set the X coordinates.
  15.        pLocation.Y = (Me.Top + (Me.Height - Form_to_Center.Height) / 2) '// set the Y coordinates.
  16.        Return pLocation '// return the Location to the Form it was called from.
  17.    End Function
  18.  
  19. #End Region

Form secundario:
Código
  1.    Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  2.        Me.Location = Form1.centerForm(Me, Me.Location)
  3.    End Sub
  4.  
9839  Programación / .NET (C#, VB.NET, ASP) / Re: Sugerencias sobre el diseño de esta APP en: 8 Enero 2013, 16:49 pm
tendré en cuenta sus sugerencias, gracias
9840  Programación / .NET (C#, VB.NET, ASP) / [SOLUCIONADO] Obtener todos los recursos de tipo TEXTO de My.Resources en: 8 Enero 2013, 16:45 pm
Esto no sé hacerlo así que he buscado en Google,
He probado las 2 maneras que se comentan aquí pero ninguna me funciona: http://stackoverflow.com/questions/1000510/how-to-get-the-names-of-all-resources-in-a-resource-file

Necesito hacer algo así:

Código
  1.   Private Sub SearchInResources(ByVal PatternSTR As String)
  2.        For Each ResourceFile In My.Resources ' Esto no funciona cláramente xD
  3.            If ResourceFile.EndsWith(".txt") Then
  4.                Dim fileContent As String = ResourceFile
  5.                Dim stringStream As New System.IO.StringReader(fileContent)
  6.                If stringStream.contains(PatternSTR) Then
  7.                    ' Cosas...
  8.                End If
  9.            End If
  10.        Next
  11.    End Sub
Páginas: 1 ... 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 [984] 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 ... 1236
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines