|
831
|
Programación / .NET (C#, VB.NET, ASP) / Como puedo crear este thread?
|
en: 26 Noviembre 2012, 12:44 pm
|
Hola, A ver, tengo un richtextbox que "printa" información hasta finalizar el búcle FOR Lo que pasa es que mi form se cuelga, no puedo tocar NADA, Lo que necesito es poder detener (detener del todo) el proceso o mantenerlo en espera (Pause) mediante un botón, o un evento de teclado, o las dos cosas!, pero preferiblemente un botón que esté destinado a pausar el proceso, y otro botón destinado a detener el proceso por completo. ¿Alguien me puede indicar como hacerlo porfavor? No lo quiero hecho, quiero aprender a hacerlo pero no se por donde buscar! Muchas gracias. Public Sub MediaInfoWorkWithFilesInDir(ByVal aDir As DirectoryInfo) Dim aFile As FileInfo For Each aFile In aDir.GetFiles() If accepted_extensions.ToLower.Contains(aFile.Extension.ToLower) Then MI.Open(aFile.FullName) Dim Pos As Integer = 0 To_Display = Nothing While Pos < MI.Count_Get(StreamKind.Audio) To_Display += "| " + MI.Get_(StreamKind.Audio, Pos, "Format") System.Math.Max(System.Threading.Interlocked.Increment(Pos), Pos - 1) End While consolebox.AppendText("Processing: " + aFile.ToString() + To_Display.ToString() + vbNewLine) consolebox.SelectionStart = consolebox.Text.Length consolebox.ScrollToCaret() End If Next End Sub
|
|
|
832
|
Programación / .NET (C#, VB.NET, ASP) / (SOLUCIONADO) Se puede mejorar este FOR?
|
en: 26 Noviembre 2012, 10:15 am
|
Hola, Mi app trabaja sobre MILES de archivos y quisiera saber si puedo mejorar este for para disminuir el tiempo de procesado: Dim accepted_extensions As String = ".264 .3gp .asf .asx .avi .avc .bsf .bdmv .divx .dv .evo .f4v .flv .hdmov .m1v .m2t .m2ts .m2v .m4v .mkv .mov .mp4 .mpeg .mpg .mpv4 .mts .ogm .ogv .qt .rmvb .swf .ts .vob .webm .wmv" Public Sub PlaylistsWorkWithFilesInDir(ByVal aDir As DirectoryInfo) consolebox.AppendText("Processing: " + aDir.ToString() + vbNewLine) consolebox.SelectionStart = consolebox.Text.Length consolebox.ScrollToCaret() Dim aFile As FileInfo For Each aFile In aDir.GetFiles() If accepted_extensions.ToLower.Contains(aFile.Extension.ToLower) Then Using writer As StreamWriter = New StreamWriter(aFile.DirectoryName.ToString() & "\" & aDir.Name & ".m3u", True, System.Text.Encoding.UTF8) writer.WriteLine(aFile.FullName.ToString()) End Using End If Next End Sub
Me pregunto si existirá algún método en el sistema para comprobar si el archivo es un archivo de video, algo así: If IO.FileType(aFile) = "VideoFile" Then...
|
|
|
833
|
Programación / .NET (C#, VB.NET, ASP) / (SOLUCIONADO) Mostrar el output de la CMD
|
en: 25 Noviembre 2012, 20:05 pm
|
Hola, Tengo una pregunta antes de la verdadera pregunta xD ¿Que control es el más adecuado para mostrar el output de la CMD? (Estoy usando un richtextbox) Y bueno, el problema es que no consigo que el texto cambie antes d emostrar el output: Me.consolebox.Text = "Deleting the attributes of the files..."
Todo lo demás funciona bien, pero no consigo mostrar ese string, se queda el richtextbox vacío hasta que finaliza el búcle... Private Function attrib() As Boolean Me.consolebox.Text = "Deleting the attributes of the files..." Dim attrib_process As New Process() Dim attrib_startinfo As New ProcessStartInfo() Dim attrib_args As String = videofolder attrib_startinfo.FileName = "cmd.exe " attrib_startinfo.UseShellExecute = False attrib_startinfo.CreateNoWindow = True attrib_startinfo.Arguments = "/C PUSHD " & ControlChars.Quote & videofolder & ControlChars.Quote & " & Attrib -A -R -S -H -I /S *.* & attrib +H /S *.ico >nul & attrib +H -R /S *.ini >nul" attrib_startinfo.RedirectStandardOutput = True attrib_process.EnableRaisingEvents = True attrib_process.StartInfo = attrib_startinfo attrib_process.Start() Dim readerStdOut As IO.StreamReader = attrib_process.StandardOutput Do While readerStdOut.EndOfStream = False output = output + readerStdOut.ReadLine() Loop Me.consolebox.Text = "This is the result of the command:" + output End Function
¿Y si necesito usar un comando de múltiples líneas como le hago? por ejemplo: attrib_startinfo.Arguments = "/C Echo linea 1 & (Echo linea2 Echo linea 3) "
|
|
|
835
|
Programación / .NET (C#, VB.NET, ASP) / Ayuda para corregir error visual redrawing effect en mi form
|
en: 24 Noviembre 2012, 09:41 am
|
Como reproducir este error? 1. Crear un nuevo winform 2. Seleccionar una imagen de fondo para el form 3. Añadir un panel 4. Cambiar la spropiedades del panel a "Color=Transparent", "AutoScroll=True", y añadr unos cuantos controles dentro del panel. Ejemplo: 5. Ahora scrollear arriba o abajo y...
¿Como corregir este error? Yo: He probado todo lo que me han aconsejado expertos, y sigo sin tener idea. El método de Invalidate o Refresh soamente disimulan el problema real y crean otro problema, porque se "flashea" el panel todo el rato si scrolleamos. Una solución sería crear una vScrollbar para mi panel, y cambiar el mínimo de scroll-lines al usar la mouse-wheel, por ejemplo scrollear 15 lineas en vez de las 6 por defecto, ya que si scrolleo una página entera no tengo ningún problema visual. Pero esto no se hacerlo por mi mismo, si alguien me pudiera dar un ejemplo se lo agradecería mucho, pues con esto ya podría terminar mi app.
Más información: (Supuestas soluciones que a mi no me han servido del todo, quizás no he sabido usarlas correctamente) http://stackoverflow.com/questions/13516557/visual-problems-with-the-form-background-imagehttp://stackoverflow.com/questions/13535693/change-mouse-wheel-scroll-lineshttp://www.daniweb.com/software-development/vbnet/threads/441204/how-to-correct-a-redrawing-background-cutted-effect-inside-a-panelhttp://www.vbdotnetforums.com/vb-net-general-discussion/54165-how-correct-redrawing-background-cutted-effect-inside-panel.html#post153014
|
|
|
837
|
Programación / .NET (C#, VB.NET, ASP) / (SOLUCIONADO) Adjuntar DLL dentro del Executable?
|
en: 23 Noviembre 2012, 15:43 pm
|
Estoy siguiendo estos pasos: Add the desired assembly (stdlib.dll) to the project's resources. Go to the Resources tab of the Project Properties and choose Add Resource > Add Existing File... Switch to the Application tab and click on the View Application Events button. Add this code to the ApplicationEvents.vb code that opens. Private Sub AppStart(ByVal sender As Object, ByVal e As Microsoft.VisualBasic.ApplicationServices.StartupEventArgs) Handles Me.Startup AddHandler AppDomain.CurrentDomain.AssemblyResolve, AddressOf ResolveAssemblies End Sub Private Function ResolveAssemblies(sender As Object, e As System.ResolveEventArgs) As Reflection.Assembly Dim desiredAssembly = New Reflection.AssemblyName(e.Name) If desiredAssembly.Name = "the name of your assembly" Then Return Reflection.Assembly.Load(My.Resources.STDLIB) 'replace with your assembly's resource name Else Return Nothing End If End Function
Now compile your project and you'll have the dependent assembly incorporated into the output as a single file. El problema es que lo he hecho todo, pero me da error el "applicationEvents.vb" Error 1 Statement is not valid in a namespace. C:\Users\Administrador\Desktop\WindowsApplication19 - copia - copia\ApplicationEvents.vb 1 1 WindowsApplication19 Mi ApplicationEvents estaba vacío al abrirlo, no se si ese puede ser el error, quizás me falta algo, solo tengo esto : Private Sub AppStart(ByVal sender As Object, ByVal e As Microsoft.VisualBasic.ApplicationServices.StartupEventArgs) Handles Me.Startup AddHandler AppDomain.CurrentDomain.AssemblyResolve, AddressOf ResolveAssemblies End Sub Private Function ResolveAssemblies(sender As Object, e As System.ResolveEventArgs) As Reflection.Assembly Dim desiredAssembly = New Reflection.AssemblyName(e.Name) If desiredAssembly.Name = "Ookii.Dialogs.dll" Then Return Reflection.Assembly.Load(My.Resources.Ookii.Dialogs) 'replace with your assembly's resource name Else Return Nothing End If End Function
|
|
|
838
|
Programación / .NET (C#, VB.NET, ASP) / (SOLUCIONADO) Como usar un string en la propiedad ROOTFOLDER de un dialogo?
|
en: 23 Noviembre 2012, 14:37 pm
|
Hola, Lo que necesito es usar un string, por ejemplo "C:\Carpeta" en la propiedad .RootFolder del FolderBrowserDialog, que usa una enumeración. He intentado crear mi propia enumeración, pero no lo consigo... algo estaré haciendo mal: Enum lastfolder last = "C:\carpeta" End Enum
Public Sub C1Button3_Click(sender As Object, e As EventArgs) Handles folderbutton.Click Dim folderselect As New VistaFolderBrowserDialog folderselect.RootFolder = lastfolder.last folderselect.ShowNewFolderButton = True ... End Sub
|
|
|
839
|
Programación / .NET (C#, VB.NET, ASP) / (Solucionado) Problema visual con la imagen de fondo del form...
|
en: 22 Noviembre 2012, 17:05 pm
|
¿Porque pasa esto? Este es el diseño de la app: Y esto es lo que sucede si muevo el scroll hacia abajo (o hacia arriba) La imagen de fondo la usa el form, el panel tiene un "backcolor" transparente, y en fin yo creo que la mezcla de coloresy transparentes y todo eos lo he configurado bien... si necesitan más información al respecto pidanme... EDITO: He probado lo siguiente, pero solo da resultado si PINCHO en el scroll para moverlo, es decir, si uso la rueda del ratón el evento no se ejecuta...¿Como puedo reproducir este evento para la rueda dle ratón?... Private Sub Panel1_Scroll(sender As Object, e As ScrollEventArgs) Handles Panel1.Scroll Me.BackgroundImage = My.Resources.blue_music_2961____copia End Sub End Class
|
|
|
840
|
Programación / .NET (C#, VB.NET, ASP) / (solucionado) Problemas de acceso en un archivo de texto
|
en: 22 Noviembre 2012, 11:30 am
|
Tengo problemas al intentar escribir datos en un archivo de texto... Cualquier ayuda, se agradece! Las líneas del problema: If System. IO. File. Exists(Temp_file ) = True Then System. IO. File. Delete(Temp_file ) System. IO. File. Create(Temp_file )
( Cualquiera de las dos líneas, si elimino una, me da el mismo error en la otra, pero el archivo si que me lo llega a crear (vacío) ) El error: The process cannot access the file 'C:\Users\Administrador\AppData\Local\Temp\PlayList_temp.txt' because it is being used by another process. El sub: Public Sub C1Button2_Click(sender As Object, e As EventArgs) Handles Button1.Click If Not playerargs = Nothing Then Dim Str As String Dim Pattern As String = ControlChars.Quote Dim ArgsArray() As String Dim Temp_file As String = System.IO.Path.GetTempPath & "\PlayList_temp.txt" Dim objWriter As New System.IO.StreamWriter(Temp_file) Str = Replace(playerargs, " " & ControlChars.Quote, "") ArgsArray = Split(Str, Pattern) If System. IO. File. Exists(Temp_file ) = True Then System. IO. File. Delete(Temp_file ) System. IO. File. Create(Temp_file ) Dim di As New IO. DirectoryInfo(folder) Dim files As IO. FileInfo() = di. GetFiles("*") ' command to writleline 'Console.WriteLine("File Name: {0}", file.Name) 'Console.WriteLine("File Full Name: {0}", file.FullName) objWriter. Write(file. FullName) objWriter.Close() Next End If Next If randomize.Checked = True Then RandomiseFile(Temp_file) End If Process.Start(userSelectedPlayerFilePath, playerargs) If autoclose.Checked = True Then Me.Close() End If Else MessageBox.Show("You must select at least one folder...", My.Settings.APPName) End If End Sub
EDITO: Ya está, solucionado: .... If Not playerargs = Nothing Then .... Dim Temp_file As String = System.IO.Path.GetTempPath & "\PlayList_temp.txt" Using objWriter As New System.IO.StreamWriter(Temp_file, false) Dim di As New IO. DirectoryInfo(folder) Dim files As IO. FileInfo() = di. GetFiles("*") ' command to writleline 'Console.WriteLine("File Name: {0}", file.Name) 'Console.WriteLine("File Full Name: {0}", file.FullName) objWriter. Write(file. FullName) ' objWriter.Close() Next End If Next End Using ' Flush, close and dispose the objWriter ....
|
|
|
|
|
|
|