The target version of the .NET Framework in the project does not match the .NET Framework launch condition version '.NET Framework 4'. Update the version of the .NET Framework launch condition to match the target version of the .NET Framework in the Advanced Compile Options Dialog Box (VB) or the Application Page (C#, F#).
1. Setup
2. Click mouse right button and select View options Launch Conditions
3. Select Launch conditions properties and change version framework prerequisites, example: .NET Framework 3.5
fuente
viernes, 28 de junio de 2019
warning windows service
Etiquetas:
Framework,
windows service
miércoles, 26 de junio de 2019
Obtener el primer directorio después del directorio raíz
Dim dir As System.IO.FileInfo = New System.IO.FileInfo(nombre_archivo)
dir.Directory.Parent.FullName
dir.Directory.Parent.FullName
Etiquetas:
directorio,
Directory,
FileInfo
martes, 25 de junio de 2019
obtener el nombre del directorio de un archivo
ejemplo:
c:\tareas\archivo.xml --->tareas
return Path.GetFileName(Path.GetDirectoryName(c:\tareas\archivo.xml))
fuente
c:\tareas\archivo.xml --->tareas
return Path.GetFileName(Path.GetDirectoryName(c:\tareas\archivo.xml))
fuente
Etiquetas:
GetDirectoryName,
GetFileName,
Path
The underlying connection was closed
The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.
solución:
ServicePointManager.ServerCertificateValidationCallback = AddressOf ValidateRemoteCertificate
'Public Shared Function ValidateRemoteCertificate(ByVal sender As Object, ByVal certificate As X509Certificate, ByVal chain As X509Chain, ByVal sslPolicyErrors As Net.Security.SslPolicyErrors) As Boolean
' Return True
'End Function
fuente
solución:
ServicePointManager.ServerCertificateValidationCallback = AddressOf ValidateRemoteCertificate
'Public Shared Function ValidateRemoteCertificate(ByVal sender As Object, ByVal certificate As X509Certificate, ByVal chain As X509Chain, ByVal sslPolicyErrors As Net.Security.SslPolicyErrors) As Boolean
' Return True
'End Function
fuente
viernes, 21 de junio de 2019
archivo bloqueado
Dim ok As Boolean = file_is_lock(New FileInfo(archivo))
Public Function file_is_lock(ByVal f As FileInfo) As Boolean
Dim stream As FileStream = Nothing
Try
stream = f.Open(FileMode.Open, FileAccess.Read, FileShare.None)
Catch ex As Exception
Return True
Finally
If Not stream Is Nothing Then
stream.Close()
End If
End Try
Return False
End Function
martes, 18 de junio de 2019
Certificación
IDK= 100
IDK= 300
lunes, 17 de junio de 2019
guardar xml con caracteres especiales < > / &
Public Sub guardar_query_cv(ByVal nodo As String, ByVal query_sql As String)
Dim doc As New XmlDocument
doc.Load(Directory.GetCurrentDirectory & "\" & Form1.archivoConfiguracion)
Dim xnode As XmlNode = doc.GetElementsByTagName(nodo)(0)
xnode.InnerXml = System.Security.SecurityElement.Escape(query_sql)
doc.Save(Directory.GetCurrentDirectory & "\" & Form1.archivoConfiguracion)
End Sub
fuente
fuente1
fuente2
jueves, 13 de junio de 2019
obtener el número de línea achivo xml
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim xdoc As XDocument = XDocument.Load("archivo.xml", LoadOptions.SetLineInfo)
Dim categories As IEnumerable(Of XElement) = xdoc.Descendants("TipoDespacho")
For Each category As XElement In categories
Dim lineNumber As Integer = CType(category, IXmlLineInfo).LinePosition
Next
End Sub
Dim xdoc As XDocument = XDocument.Load("archivo.xml", LoadOptions.SetLineInfo)
Dim categories As IEnumerable(Of XElement) = xdoc.Descendants("TipoDespacho")
For Each category As XElement In categories
Dim lineNumber As Integer = CType(category, IXmlLineInfo).LinePosition
Next
End Sub
TabControl TabPage agregar/remover
string a archivo
File.WriteAllText(Directory.GetCurrentDirectory & "\" & "blob.xml", caf_string)
File.WriteAllText(ruta_destino_archivo,dim_string)
Etiquetas:
File,
String,
WriteAllText
Insertar nodo xml antes o después de un elemento
Private Sub bt_insert_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt_insert.Click
' Insertar el nodo asdf, después del nodo TipoDTE
'doc.PreserveWhitespace = True
doc.Load("DTE33.xml")
Dim elem As XmlNode = doc.CreateElement("asdf")
elem.InnerXml = "456"
Dim node As XmlNode = doc.GetElementsByTagName("IdDoc")(0)
Dim x As XmlElement = doc.GetElementsByTagName("IdDoc")(0).Item("TipoDTE") 'node("TipoDTE")
node.InsertAfter(elem, x)
doc.Save("DTE33.xml")
End Sub
fuente
' Insertar el nodo asdf, después del nodo TipoDTE
'doc.PreserveWhitespace = True
doc.Load("DTE33.xml")
Dim elem As XmlNode = doc.CreateElement("asdf")
elem.InnerXml = "456"
Dim node As XmlNode = doc.GetElementsByTagName("IdDoc")(0)
Dim x As XmlElement = doc.GetElementsByTagName("IdDoc")(0).Item("TipoDTE") 'node("TipoDTE")
node.InsertAfter(elem, x)
doc.Save("DTE33.xml")
End Sub
fuente
Etiquetas:
InsertAfter,
InsertBefore,
xml
miércoles, 12 de junio de 2019
For each array
For Each c As String In New String() {"1", "2", "3", "4"}
MessageBox.Show(c)
Next
MessageBox.Show(c)
Next
martes, 11 de junio de 2019
borrar múltiples filas datagridview
Dim selectedCellCount As Integer = dgv_nodos_sii.SelectedRows.Count
Dim j As DataGridViewSelectedRowCollection = dgv_nodos_sii.SelectedRows
Seleccionar filas de mayor a menor
For Each row As DataGridViewRow In dgv_nodos_sii.SelectedRows
MessageBox.Show(row.Index)
Next
Seleccionar filas de menor a mayor
For Each row As DataGridViewRow In dgv_nodos_sii.SelectedRows.Cast(Of DataGridViewRow).OrderBy(Function(dgvr) dgvr.Index)
MessageBox.Show(row.Index)
Next
fuente
viernes, 7 de junio de 2019
seleccionar item automaticamente
ToolTip listbox
Private Sub lb_dte_MouseMove(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles lb_dte.MouseMove
Dim i As Integer = lb_dte.IndexFromPoint(e.Location)
If i > -1 Then
Dim tip As String = lb_dte.Items(i).ToString
'Dim tipw As ToolTip = Nothing
If tip = 33 Then
tip = "Factura electrónica"
ElseIf tip = 34 Then
tip = "Factura exenta"
ElseIf tip = 39 Then
tip = "Boleta electrónica"
ElseIf tip = 41 Then
tip = "Boleta exenta"
ElseIf tip = 43 Then
ElseIf tip = 46 Then
End If
If (ToolTip1.GetToolTip(lb_dte) IsNot tip) Then
ToolTip1.SetToolTip(lb_dte, tip)
End If
End If
End Sub
Dim i As Integer = lb_dte.IndexFromPoint(e.Location)
If i > -1 Then
Dim tip As String = lb_dte.Items(i).ToString
'Dim tipw As ToolTip = Nothing
If tip = 33 Then
tip = "Factura electrónica"
ElseIf tip = 34 Then
tip = "Factura exenta"
ElseIf tip = 39 Then
tip = "Boleta electrónica"
ElseIf tip = 41 Then
tip = "Boleta exenta"
ElseIf tip = 43 Then
ElseIf tip = 46 Then
End If
If (ToolTip1.GetToolTip(lb_dte) IsNot tip) Then
ToolTip1.SetToolTip(lb_dte, tip)
End If
End If
End Sub
jueves, 6 de junio de 2019
ordenar listbox
Dim arr() As Integer = New Integer(lb_dte_activo.Items.Count - 1) {}
Dim i As Integer = 0
For Each elem In lb_dte_activo.Items
arr(i) = elem
i += 1
Next
Array.Sort(arr)
'lb_dte_activo.Sorted = False
lb_dte_activo.Items.Clear()
lb_dte_activo.Items.AddRange(arr.Cast(Of Object).ToArray())
fuente
Dim i As Integer = 0
For Each elem In lb_dte_activo.Items
arr(i) = elem
i += 1
Next
Array.Sort(arr)
'lb_dte_activo.Sorted = False
lb_dte_activo.Items.Clear()
lb_dte_activo.Items.AddRange(arr.Cast(Of Object).ToArray())
fuente
contar elementos de un nodo
Dim i As Integer = doc.GetElementsByTagName(nodo)(0).ChildNodes.Count
miércoles, 5 de junio de 2019
crear setgesys
Private Sub btn_envio_xml_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_envio_xml.Click
Dim lineas As New ArrayList
Dim txt() As String = File.ReadAllLines("D:\z\brown\tasks\tasks\bin\Debug\DTEOK\DTE33F10331.xml", Encoding.GetEncoding("ISO-8859-1"))
lineas.AddRange(txt)
lineas.Insert(1, "<SetGESYS xmlns=""http://www.sii.cl/SiiDte"">")
lineas.Insert(2, " <Extras>")
lineas.Insert(3, " </Extras>")
lineas.Add("</SetGESYS>")
'txt(1) = " <EnvioDTE xmlns=""http://www.sii.cl/SiiDte"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xsi:schemaLocation=""http://www.sii.cl/SiiDte EnvioDTE_v10.xsd"" version=""1.0"">"
'txt(1) = "<SetGESYS xmlns=""http://www.sii.cl/SiiDte"">"
'File.WriteAllText("D:\z\brown\tasks\tasks\bin\Debug\DTEOK" & "\" & "gesys.xml2", , System.Text.Encoding.GetEncoding("ISO-8859-1")) ' sólo prueba
File.WriteAllLines("D:\z\brown\tasks\tasks\bin\Debug\DTEOK" & "\" & "archivo.xml", lineas.Cast(Of String).ToArray, System.Text.Encoding.GetEncoding("ISO-8859-1"))
End Sub
Dim lineas As New ArrayList
Dim txt() As String = File.ReadAllLines("D:\z\brown\tasks\tasks\bin\Debug\DTEOK\DTE33F10331.xml", Encoding.GetEncoding("ISO-8859-1"))
lineas.AddRange(txt)
lineas.Insert(1, "<SetGESYS xmlns=""http://www.sii.cl/SiiDte"">")
lineas.Insert(2, " <Extras>")
lineas.Insert(3, " </Extras>")
lineas.Add("</SetGESYS>")
'txt(1) = " <EnvioDTE xmlns=""http://www.sii.cl/SiiDte"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xsi:schemaLocation=""http://www.sii.cl/SiiDte EnvioDTE_v10.xsd"" version=""1.0"">"
'txt(1) = "<SetGESYS xmlns=""http://www.sii.cl/SiiDte"">"
'File.WriteAllText("D:\z\brown\tasks\tasks\bin\Debug\DTEOK" & "\" & "gesys.xml2", , System.Text.Encoding.GetEncoding("ISO-8859-1")) ' sólo prueba
File.WriteAllLines("D:\z\brown\tasks\tasks\bin\Debug\DTEOK" & "\" & "archivo.xml", lineas.Cast(Of String).ToArray, System.Text.Encoding.GetEncoding("ISO-8859-1"))
End Sub
cargar nodos xml
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim doc As New XmlDocument
doc.Load("archivo.xml")
Dim xml_nodos As XmlNode = doc.GetElementsByTagName("IdDoc")(0)
Dim array() As String = Nothing
For Each elem As XmlNode In xml_nodos
array = {"", False, False, False, False, False}
array(0) = elem.Name
Dim dte() As Integer = elem.InnerXml.Split(",").Select(Function(x) Int32.Parse(x)).ToArray
For Each tipo_dte In dte
Select Case tipo_dte
Case 33
array(1) = True
Case 34
array(2) = True
Case 39
array(3) = True
Case 56
array(4) = True
Case 61
array(5) = True
End Select
Next
DataGridView1.Rows.Add(array)
Next
'Dim xml As New Xml.XmlTextReader("archivo.xml")
'While xml.Read
' If xml.NodeType = System.Xml.XmlNodeType.Element Then
' MessageBox.Show(xml.Name)
' End If
'End While
End Sub
Dim doc As New XmlDocument
doc.Load("archivo.xml")
Dim xml_nodos As XmlNode = doc.GetElementsByTagName("IdDoc")(0)
Dim array() As String = Nothing
For Each elem As XmlNode In xml_nodos
array = {"", False, False, False, False, False}
array(0) = elem.Name
Dim dte() As Integer = elem.InnerXml.Split(",").Select(Function(x) Int32.Parse(x)).ToArray
For Each tipo_dte In dte
Select Case tipo_dte
Case 33
array(1) = True
Case 34
array(2) = True
Case 39
array(3) = True
Case 56
array(4) = True
Case 61
array(5) = True
End Select
Next
DataGridView1.Rows.Add(array)
Next
'Dim xml As New Xml.XmlTextReader("archivo.xml")
'While xml.Read
' If xml.NodeType = System.Xml.XmlNodeType.Element Then
' MessageBox.Show(xml.Name)
' End If
'End While
End Sub
martes, 4 de junio de 2019
verificar datos null
If dr(3) Is DBNull.Value Then
Continue For
End If
Continue For
End If
Suscribirse a:
Entradas (Atom)