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úImports System.Drawing.Drawing2D
Imports System.Drawing.Imaging
Public NotInheritable Class Form1 : Inherits Form
Friend WithEvents PcbPreview As PictureBox
Friend WithEvents BtLoad As Button
Friend WithEvents BtSave As Button
Friend WithEvents TrckHue As TrackBar
Friend WithEvents LblHue As Label
Private srcImg As Image
Private thumbnail As Image
Public Sub New()
MyClass.InitializeComponent()
Me.Size = New Size(520, 400)
Me.DoubleBuffered = True
Me.PcbPreview = New PictureBox With {
.Location = New Point(10, 10),
.Size = New Size(400, 240),
.SizeMode = PictureBoxSizeMode.Normal,
.BackColor = Color.DarkGray
}
Me.BtLoad = New Button With {
.Location = New Point(Me.PcbPreview.Width + 20, 10),
.Text = "Load from..."
}
Me.BtSave = New Button With {
.Location = New Point(Me.PcbPreview.Width + 20, 40),
.Text = "Save to..."
}
Me.TrckHue = New TrackBar With {
.Location = New Point(10, Me.PcbPreview.Height + 20),
.AutoSize = True,
.Size = New Size(Me.PcbPreview.Width, 10),
.TickStyle = TickStyle.TopLeft,
.BackColor = Color.DarkGray,
.TickFrequency = 50,
.Maximum = 100,
.Minimum = -100,
.Value = 0,
.Orientation = Orientation.Horizontal
}
Me.LblHue = New Label With {
.Location = New Point(Me.TrckHue.Width + 20, Me.TrckHue.Top + 10),
.AutoSize = True,
.Text = "0",
.Font = New Font("Arial", 20, FontStyle.Bold)
}
Me.LblHue.BringToFront()
End Sub
Private Sub Form1_Shown(ByVal sender As Object, ByVal e As EventArgs) _
Handles Me.Shown
Me.SuspendLayout()
Me.Controls.AddRange({Me.PcbPreview, Me.BtLoad, Me.BtSave, Me.TrckHue, Me.LblHue})
Me.ResumeLayout()
End Sub
Private Sub BtLoad_Click(ByVal sender As Object, ByVal e As EventArgs) _
Handles BtLoad.Click
Using ofd As New OpenFileDialog()
ofd.Title = "Open image"
ofd.Filter = "Image files|*.jpg;*.png;*.bmp"
If (ofd.ShowDialog() = DialogResult.OK) Then
If (Me.srcImg IsNot Nothing) Then
Me.srcImg.Dispose()
End If
Me.srcImg = Image.FromFile(ofd.FileName)
If (Me.thumbnail IsNot Nothing) Then
Me.thumbnail.Dispose()
End If
Dim thumbSize As Size = Me.PcbPreview.Size
Me.thumbnail = Me.srcImg.GetThumbnailImage(thumbSize.Width, thumbSize.Heigth, Nothing, Nothing)
' Force TrackBar.OnValueChanged event to trigger.
Me.TrckHue.Value = 1
Me.TrckHue.Value = 0
End If
End Using ' ofd
End Sub
Private Sub BtSave_Click(ByVal sender As Object, ByVal e As EventArgs) _
Handles BtSave.Click
Using sfd As New SaveFileDialog()
sfd.Title = "Save image"
sfd.Filter = "Bitmap image|*.bmp|Jpeg image|*.jpg|PNG image|*.png"
sfd.AddExtension = True
If (sfd.ShowDialog() = DialogResult.OK) Then
Dim file As New FileInfo(sfd.FileName)
Dim ext As String = file.Extension.ToLower()
Dim format As ImageFormat
Select Case ext
Case ".png"
format = ImageFormat.Png
Case ".bmp"
format = ImageFormat.Bmp
Case Else ' jpg
format = ImageFormat.Jpeg
End Select
Dim factor As Single = (Me.TrckHue.Value + 100)
Using img As Image = Me.srcImg.SetImageSaturation(factor, highQuality:=True)
img.Save(file.FullName, format)
End Using ' img
End If
End Using ' sfd
End Sub
Private Sub TrckHue_ValueChanged(ByVal sender As Object, ByVal e As EventArgs) _
Handles TrckHue.ValueChanged
Dim trck As TrackBar = DirectCast(sender, TrackBar)
Dim value As Integer = trck.Value
Dim factor As Single = (trck.Value + 100)
Dim pcbUpdate As Action =
Sub()
Me.LblHue.Invoke(Sub()
Me.LblHue.Text = CStr(value)
Me.Update()
End Sub)
Dim lockImg As Image = Me.thumbnail
SyncLock lockImg
lockImg = lockImg.SetImageSaturation(factor, highQuality:=False)
Me.PcbPreview.Image = lockImg
End SyncLock
End Sub
Task.Factory.StartNew(pcbUpdate)
End Sub
End Class
Public Module ImageExtensions
<DebuggerStepThrough>
<Extension>
<EditorBrowsable(EditorBrowsableState.Always)>
Public Function SetImageSaturation(ByVal srcImg As Image, ByVal factor As Single,
ByVal highQuality As Boolean) As Image
Dim r As Single = (299 * (100 - factor) / 100000.0F)
Dim g As Single = (587 * (100 - factor) / 100000.0F)
Dim b As Single = (114 * (100 - factor) / 100000.0F)
factor = (factor / 100.0F)
Dim bmp As New Bitmap(srcImg.Width, srcImg.Height, srcImg.PixelFormat)
Dim matrix As Single()() = {
New Single() {(r + factor), r, r, 0.0F, 0.0F},
New Single() {g, (g + factor), g, 0.0F, 0.0F},
New Single() {b, b, (b + factor), 0.0F, 0.0F},
New Single() {0.0F, 0.0F, 0.0F, 1.0F, 0.0F},
New Single() {0.0F, 0.0F, 0.0F, 0.0F, 1.0F}
} ' Esta matriz de color la ideó el usuario @FJDA con el propósito de saturar una imagen.
Using ia As New ImageAttributes
ia.ClearColorMatrix()
ia.SetColorMatrix(New ColorMatrix(matrix), ColorMatrixFlag.Default, ColorAdjustType.Bitmap)
ia.SetGamma(1.0F, ColorAdjustType.Bitmap)
Using gdi As Graphics = Graphics.FromImage(bmp)
With gdi
If highQuality Then
.CompositingQuality = CompositingQuality.HighQuality
.InterpolationMode = InterpolationMode.HighQualityBicubic
.PixelOffsetMode = PixelOffsetMode.HighQuality
.SmoothingMode = SmoothingMode.HighQuality
Else
.CompositingQuality = CompositingQuality.HighSpeed
.InterpolationMode = InterpolationMode.NearestNeighbor
.PixelOffsetMode = PixelOffsetMode.None
.SmoothingMode = SmoothingMode.None
End If
.DrawImage(srcImg, New Rectangle(0, 0, bmp.Width, bmp.Height),
0, 0, srcImg.Width, srcImg.Height,
GraphicsUnit.Pixel, ia)
End With
End Using ' gdi
End Using ' ia
Return bmp
End Function
End Module
Cita de: FJDA en 16 Septiembre 2016, 16:45 PMestoy intentando saturar una imagen
...
el programa tarda mucho en procesar los cambios.
...
no va bien.
...
al usar un TrackBar el proceso de los cambios es demasiado lento.
Cita de: FJDA en 16 Septiembre 2016, 16:45 PMDim Grafico As Graphics
...
Grafico.DrawImage(...)
Cita de: FJDA en 16 Septiembre 2016, 16:45 PMDim PictureBox1 As New PictureBox With {...
.SizeMode = PictureBoxSizeMode.StretchImage,
...}
Cita de: FJDA en 16 Septiembre 2016, 21:06 PMIntenté usar funciones que PictureBox tiene en C# que simplifican mucho todo pero no están disponibles en VB
Cita de: TrashAmbishion en 16 Septiembre 2016, 04:44 AMEl cancela el worker pero no se activa el RunWorkerComplete nunca...
Public Class Form1 : Inherits Form
Private ReadOnly worker As New BWorkerProc
Private Sub Button_Start_Click() Handles Button1.Click
Me.worker.StartBackgroundTask()
End Sub
Private Sub Button_Stop_Click() Handles Button2.Click
Me.worker.Cancel()
End Sub
End Class
....
Private Sub MyWorker_DoWork(ByVal sender As Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles MyWorker.DoWork
Do Until MyWorker.CancellationPending
Continue Do
Loop
e.Cancel = True
End Sub
Private Sub MyWorker_RunWorkerCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.RunWorkerCompletedEventArgs) _
Handles myWorker.RunWorkerCompleted
If e.Cancelled = True Then
MsgBox("Thread cancelled")
End If
End Sub
....
#Region " Option Statements "
Option Strict On
Option Explicit On
Option Infer Off
#End Region
#Region " Imports "
Imports System.ComponentModel
Imports System.Diagnostics
Imports System.Threading
#End Region
#Region " BackgroundWorker State "
''' ----------------------------------------------------------------------------------------------------
''' <summary>
''' Specifies the state of a <see cref="BackgroundWorker"/>.
''' </summary>
''' ----------------------------------------------------------------------------------------------------
Public Enum BackgroundWorkerState As Integer
''' <summary>
''' The <see cref="BackgroundWorker"/> is stopped.
''' </summary>
Stopped = 0
''' <summary>
''' The <see cref="BackgroundWorker"/> is running.
''' </summary>
Running = 1
''' <summary>
''' The <see cref="BackgroundWorker"/> is paused.
''' </summary>
Paused = 2
''' <summary>
''' The <see cref="BackgroundWorker"/> is pending on a cancellation.
''' </summary>
CancellationPending = 3
''' <summary>
''' The <see cref="BackgroundWorker"/> is completed (stopped).
''' </summary>
Completed = 4
End Enum
#End Region
#Region " My Background Work "
Public NotInheritable Class MyBackgroundWork : Implements IDisposable
#Region " Private Fields "
''' ----------------------------------------------------------------------------------------------------
''' <summary>
''' The underliying <see cref="BackgroundWorker"/> instance that runs this work on background.
''' </summary>
''' ----------------------------------------------------------------------------------------------------
<EditorBrowsable(EditorBrowsableState.Never)>
Friend WithEvents Worker As BackgroundWorker
''' ----------------------------------------------------------------------------------------------------
''' <summary>
''' A <see cref="ManualResetEvent"/> that serves to handle synchronous operations (Run, Pause, Resume, Cancel).
''' </summary>
''' ----------------------------------------------------------------------------------------------------
Private ReadOnly mreSync As ManualResetEvent
''' ----------------------------------------------------------------------------------------------------
''' <summary>
''' A <see cref="ManualResetEvent"/> that serves to handle asynchronous operations (RunAsync, CancelAsync).
''' </summary>
''' ----------------------------------------------------------------------------------------------------
Private ReadOnly mreAsync As ManualResetEvent
''' ----------------------------------------------------------------------------------------------------
''' <summary>
''' Indicates whether <see cref="BackGroundworker"/> has been initiated in synchronous mode.
''' </summary>
''' ----------------------------------------------------------------------------------------------------
Private isRunSync As Boolean = False
''' ----------------------------------------------------------------------------------------------------
''' <summary>
''' Indicates whether a synchronous cancellation operation is requested.
''' </summary>
''' ----------------------------------------------------------------------------------------------------
Private isCancelSyncRequested As Boolean = False
''' ----------------------------------------------------------------------------------------------------
''' <summary>
''' Indicates whether a pause operation is requested.
''' </summary>
''' ----------------------------------------------------------------------------------------------------
Private isPauseRequested As Boolean = False
#End Region
#Region " Properties "
''' ----------------------------------------------------------------------------------------------------
''' <summary>
''' Gets the current state of the background work.
''' </summary>
''' ----------------------------------------------------------------------------------------------------
''' <value>
''' The current state of the background work.
''' </value>
''' ----------------------------------------------------------------------------------------------------
Public ReadOnly Property State As BackgroundWorkerState
<DebuggerStepThrough>
Get
Return Me.stateB
End Get
End Property
''' ----------------------------------------------------------------------------------------------------
''' <summary>
''' ( Backing Field )
''' The current state of the background work.
''' </summary>
''' ----------------------------------------------------------------------------------------------------
Private stateB As BackgroundWorkerState = BackgroundWorkerState.Stopped
#End Region
#Region " Constructors "
''' ----------------------------------------------------------------------------------------------------
''' <summary>
''' Initializes a new instance of the <see cref="MyBackgroundWork"/> class.
''' </summary>
''' ----------------------------------------------------------------------------------------------------
<DebuggerNonUserCode>
Public Sub New()
Me.Worker = New BackgroundWorker()
Me.mreSync = New ManualResetEvent(initialState:=False)
Me.mreAsync = New ManualResetEvent(initialState:=True)
End Sub
#End Region
#Region " Public Methods "
''' ----------------------------------------------------------------------------------------------------
''' <summary>
''' Run the background work.
''' </summary>
''' ----------------------------------------------------------------------------------------------------
''' <exception cref="InvalidOperationException">
''' In order to run the BackgroundWorker instance it must be stopped or completed.
''' </exception>
''' ----------------------------------------------------------------------------------------------------
<DebuggerStepThrough>
Public Sub Run()
If (Me.Worker Is Nothing) Then
Throw New ObjectDisposedException(objectName:="Worker")
Else
Select Case Me.stateB
Case BackgroundWorkerState.Stopped, BackgroundWorkerState.Completed
Me.isRunSync = True
With Me.Worker
.WorkerSupportsCancellation = False
.WorkerReportsProgress = False
.RunWorkerAsync()
End With
Me.stateB = BackgroundWorkerState.Running
Me.mreSync.WaitOne()
Case Else
Throw New InvalidOperationException("In order to run the BackgroundWorker instance it must be stopped or completed.")
End Select
End If
End Sub
''' ----------------------------------------------------------------------------------------------------
''' <summary>
''' Asynchronouslly run the background work.
''' </summary>
''' ----------------------------------------------------------------------------------------------------
''' <exception cref="InvalidOperationException">
''' In order to run the BackgroundWorker instance it must be stopped or completed.
''' </exception>
''' ----------------------------------------------------------------------------------------------------
<DebuggerStepThrough>
Public Sub RunAsync()
If (Me.Worker Is Nothing) Then
Throw New ObjectDisposedException(objectName:="Worker")
Else
Select Case Me.stateB
Case BackgroundWorkerState.Stopped, BackgroundWorkerState.Completed
With Me.Worker
.WorkerSupportsCancellation = True
.WorkerReportsProgress = True
.RunWorkerAsync()
End With
Me.stateB = BackgroundWorkerState.Running
Case Else
Throw New InvalidOperationException("In order to run the BackgroundWorker instance it must be stopped or completed.")
End Select
End If
End Sub
''' ----------------------------------------------------------------------------------------------------
''' <summary>
''' Asynchronouslly pause the background work.
''' </summary>
''' ----------------------------------------------------------------------------------------------------
''' <exception cref="InvalidOperationException">
''' In order to pause the BackgroundWorker instance it must be running.
''' </exception>
''' ----------------------------------------------------------------------------------------------------
<DebuggerStepThrough>
Public Sub PauseAsync()
If (Me.Worker Is Nothing) Then
Throw New ObjectDisposedException(objectName:="Worker")
Else
Select Case Me.stateB
Case BackgroundWorkerState.Running
Me.isPauseRequested = True
Me.stateB = BackgroundWorkerState.Paused
Me.mreAsync.Reset()
Case Else
Throw New InvalidOperationException("In order to pause the BackgroundWorker instance it must be running.")
End Select
End If
End Sub
''' ----------------------------------------------------------------------------------------------------
''' <summary>
''' Resume the background work.
''' </summary>
''' ----------------------------------------------------------------------------------------------------
''' <exception cref="InvalidOperationException">
''' In order to resume the BackgroundWorker instance it must be paused.
''' </exception>
''' ----------------------------------------------------------------------------------------------------
<DebuggerStepThrough>
Public Sub [Resume]()
If (Me.Worker Is Nothing) Then
Throw New ObjectDisposedException(objectName:="Worker")
Else
Select Case Me.stateB
Case BackgroundWorkerState.Paused
Me.stateB = BackgroundWorkerState.Running
Me.isPauseRequested = False
Me.mreAsync.Set()
Case Else
Throw New InvalidOperationException("In order to resume the BackgroundWorker instance must be paused.")
End Select
End If
End Sub
''' ----------------------------------------------------------------------------------------------------
''' <summary>
''' Cancel the background work.
''' <para></para>
''' It blocks the caller thread until the remaining work is done.
''' </summary>
''' ----------------------------------------------------------------------------------------------------
''' <exception cref="InvalidOperationException">
''' In order to cancel the BackgroundWorker instance it must be running or paused.
''' </exception>
''' ----------------------------------------------------------------------------------------------------
<DebuggerStepThrough>
Public Sub Cancel()
Me.isCancelSyncRequested = True
Me.CancelAsync()
Me.mreSync.WaitOne()
Me.isCancelSyncRequested = False
End Sub
''' ----------------------------------------------------------------------------------------------------
''' <summary>
''' Asynchronouslly cancel the background work.
''' </summary>
''' ----------------------------------------------------------------------------------------------------
''' <exception cref="InvalidOperationException">
''' In order to cancel the BackgroundWorker instance it must be running or paused.
''' </exception>
''' ----------------------------------------------------------------------------------------------------
<DebuggerStepThrough>
Public Sub CancelAsync()
If (Me.Worker Is Nothing) Then
Throw New ObjectDisposedException(objectName:="Worker")
Else
Select Case Me.stateB
Case BackgroundWorkerState.CancellationPending
Exit Sub
Case BackgroundWorkerState.Running, BackgroundWorkerState.Paused
Me.mreAsync.Set() ' Resume thread if it is paused.
Me.stateB = BackgroundWorkerState.CancellationPending
Me.Worker.CancelAsync() ' Cancel it.
Case Else
Throw New InvalidOperationException("In order to cancel the BackgroundWorker instance must be running or paused.")
End Select
End If
End Sub
#End Region
#Region " Private Methods "
<DebuggerStepperBoundary>
Private Sub DoSomething()
Thread.Sleep(TimeSpan.FromSeconds(5))
End Sub
#End Region
#Region " Event-Handlers "
''' ----------------------------------------------------------------------------------------------------
''' <summary>
''' Handles the <see cref="BackgroundWorker.DoWork"/> event of the <see cref="Worker"/> instance.
''' </summary>
''' ----------------------------------------------------------------------------------------------------
''' <param name="sender">
''' The source of the event.
''' </param>
'''
''' <param name="e">
''' The <see cref="DoWorkEventArgs"/> instance containing the event data.
''' </param>
''' ----------------------------------------------------------------------------------------------------
<DebuggerStepperBoundary>
Private Sub Worker_DoWork(ByVal sender As Object, ByVal e As DoWorkEventArgs) _
Handles Worker.DoWork
Dim progress As Integer
Dim lock As Object = ""
SyncLock lock
For i As Integer = 0 To 100
If (Me.Worker.CancellationPending) Then
e.Cancel = True
Exit For
Else
If (Me.isPauseRequested) Then ' Pause this thread right here.
Me.mreAsync.WaitOne(Timeout.Infinite)
End If
Me.DoSomething()
If Me.Worker.WorkerReportsProgress Then
progress = i
Me.Worker.ReportProgress(progress)
End If
End If
Next i
End SyncLock
If (Me.Worker.WorkerReportsProgress) AndAlso Not (Me.Worker.CancellationPending) AndAlso (progress < 100) Then
Me.Worker.ReportProgress(percentProgress:=100)
End If
If (Me.isRunSync) OrElse (Me.isCancelSyncRequested) Then
Me.mreSync.Set()
End If
End Sub
''' ----------------------------------------------------------------------------------------------------
''' <summary>
''' Handles the <see cref="BackgroundWorker.ProgressChanged"/> event of the <see cref="Worker"/> instance.
''' </summary>
''' ----------------------------------------------------------------------------------------------------
''' <param name="sender">
''' The source of the event.
''' </param>
'''
''' <param name="e">
''' The <see cref="ProgressChangedEventArgs"/> instance containing the event data.
''' </param>
''' ----------------------------------------------------------------------------------------------------
<DebuggerStepperBoundary>
Private Sub Worker_ProgressChanged(ByVal sender As Object, ByVal e As ProgressChangedEventArgs) _
Handles Worker.ProgressChanged
Console.WriteLine(String.Format("Work Progress: {0:00.00}%", e.ProgressPercentage))
End Sub
''' ----------------------------------------------------------------------------------------------------
''' <summary>
''' Handles the <see cref="BackgroundWorker.RunWorkerCompleted"/> event of the <see cref="Worker"/> instance.
''' </summary>
''' ----------------------------------------------------------------------------------------------------
''' <param name="sender">
''' The source of the event.
''' </param>
'''
''' <param name="e">
''' The <see cref="RunWorkerCompletedEventArgs"/> instance containing the event data.
''' </param>
''' ----------------------------------------------------------------------------------------------------
<DebuggerStepperBoundary>
Private Sub Worker_RunWorkerCompleted(ByVal sender As Object, ByVal e As RunWorkerCompletedEventArgs) _
Handles Worker.RunWorkerCompleted
If (e.Cancelled) Then
Console.WriteLine("Background work cancelled.")
ElseIf (e.Error IsNot Nothing) Then
Console.WriteLine("Background work error.")
Else
Console.WriteLine("Background work done.")
End If
Me.stateB = BackgroundWorkerState.Completed
End Sub
#End Region
#Region " IDisposable Implementation "
''' ----------------------------------------------------------------------------------------------------
''' <summary>
''' Flag to detect redundant calls when disposing.
''' </summary>
''' ----------------------------------------------------------------------------------------------------
Private isDisposed As Boolean
''' ----------------------------------------------------------------------------------------------------
''' <summary>
''' Releases all the resources used by this instance.
''' </summary>
''' ----------------------------------------------------------------------------------------------------
<DebuggerStepThrough>
Public Sub Dispose() Implements IDisposable.Dispose
Me.Dispose(isDisposing:=True)
GC.SuppressFinalize(obj:=Me)
End Sub
''' ----------------------------------------------------------------------------------------------------
''' <summary>
''' Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
''' <para></para>
''' Releases unmanaged and, optionally, managed resources.
''' </summary>
''' ----------------------------------------------------------------------------------------------------
''' <param name="isDisposing">
''' <see langword="True"/> to release both managed and unmanaged resources;
''' <see langword="False"/> to release only unmanaged resources.
''' </param>
''' ----------------------------------------------------------------------------------------------------
<DebuggerStepThrough>
Private Sub Dispose(ByVal isDisposing As Boolean)
If (Not Me.isDisposed) AndAlso (isDisposing) Then
If (Me.Worker IsNot Nothing) Then
Me.Worker.Dispose()
Me.Worker = Nothing
With Me.mreSync
.SafeWaitHandle.Close()
.Dispose()
End With
With Me.mreAsync
.SafeWaitHandle.Close()
.Dispose()
End With
Me.isRunSync = False
Me.stateB = BackgroundWorkerState.Stopped
End If
End If
Me.isDisposed = True
End Sub
#End Region
End Class
#End Region
Public Class Form1
Friend Worker As MyBackgroundWork
Private Sub Run_Click() Handles Button_Start.Click
If (Me.Worker IsNot Nothing) Then
Select Case Me.Worker.State
Case BackgroundWorkerState.Running, BackgroundWorkerState.Paused
Me.Worker.Cancel()
Case Else
Do Nothing.
End Select
End If
Me.Worker = New MyBackgroundWork
Me.Worker.RunAsync()
End Sub
Private Sub Pause_Click() Handles Button_Pause.Click
Me.Worker.PauseAsync()
End Sub
Private Sub Resume_Click() Handles Button_Resume.Click
Me.Worker.Resume()
End Sub
Private Sub Cancel_Click() Handles Button_Cancel.Click
Me.Worker.CancelAsync()
End Sub
End Class
Cita de: Tomas1982 en 14 Septiembre 2016, 20:27 PMcomo logro contar la cantidad de fichero por tipo de extensión
Dim groups As IEnumerable(Of IGrouping(Of String, FileInfo)) =
New DirectoryInfo(".\").EnumerateFiles("*", SearchOption.TopDirectoryOnly).
GroupBy(Of String)(Function(file As FileInfo) file.Extension)
Dim totalFileCount As Integer =
groups.Sum(Function(group As IGrouping(Of String, FileInfo)) group.Count) ' Cantidad total de archivos.
For Each group As IGrouping(Of String, FileInfo) In groups
Dim fileCount As Integer = group.Count ' Cantidad de archivos de este grupo.
...
Next group
Cita de: ill_milk en 14 Septiembre 2016, 18:48 PMAl iniciar windows me aparecen 4 mensajes que rezan lo siguiente: "El programa no puede iniciarse porque falta MSVCP100.dll [ó MSVCR100.dll en los 3 mensajes restantes]
...
he pensado (sustituir los .dll en los directorios que generen el conflicto, desinstalar y volver a instalar Microsoft Visual C++
Cita de: Elektro
Cita de: ill_milk en 14 Septiembre 2016, 18:48 PMIntente reinstalar el programa para corregir el problema." No se a que p*** programa se refiere
Dim groups As IEnumerable(Of IGrouping(Of String, FileInfo)) =
New DirectoryInfo(".\").EnumerateFiles("*", SearchOption.TopDirectoryOnly).
GroupBy(Of String)(Function(file As FileInfo) file.Extension)
For Each group As IGrouping(Of String, FileInfo) In groups
Dim sb As New StringBuilder(capacity:=(group.Count * 260)) ' Suggested capacity. 260 = MAX_PATH
With sb
.AppendFormat("Group of file extension '{0}'", group.Key)
.AppendLine()
.AppendLine(String.Join(Environment.NewLine, group))
End With
Console.WriteLine(sb.ToString())
Next group
Cita de: Visual StudioGroup of file extension: '.exe'
WindowsApplication1.exe
WindowsApplication1.vshost.exe
Group of file extension: '.config'
WindowsApplication1.exe.config
WindowsApplication1.vshost.exe.config
Group of file extension: '.pdb'
WindowsApplication1.pdb
Group of file extension: '.xml'
WindowsApplication1.xml