Visual Basic.NET - Subir Archivos al Servidor

 
Vista:
Imágen de perfil de Oscar
Val: 65
Ha aumentado su posición en 2 puestos en Visual Basic.NET (en relación al último mes)
Gráfica de Visual Basic.NET

Subir Archivos al Servidor

Publicado por Oscar (31 intervenciones) el 30/05/2018 16:21:10
Buenas tengo unos pequeños problemillas a la hora de subir el archivo al servidor este es mi codigo actual , si me funciona en entono local iniciando la aplicacion desde visual studio.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
Protected Sub ButtonArchivos_Click_Click(sender As Object, e As EventArgs) Handles ButtonDetalle.Click
 
            Dim filepath As String = Server.MapPath("\Upload")
            Dim uploadedFiles As HttpFileCollection = Request.Files
            Span1.Text = String.Empty
            Referencia = TextReferencia.Text
            'Dim dt As New DataTable()
            ''columnas
            'dt.Columns.Add("UUID")
 
 
            For i As Integer = 0 To uploadedFiles.Count - 1
                Dim userPostedFile As HttpPostedFile = uploadedFiles(i)
 
                'Try
                If userPostedFile.ContentLength > 0 Then
                    Span1.Text += "<u>File #" & (i + 1) & "</u><br>"
                    Span1.Text += "File Content Type: " & userPostedFile.ContentType & "<br>"
                    Span1.Text += "File Size: " & userPostedFile.ContentLength & "kb<br>"
                    Span1.Text += "File Name: " & userPostedFile.FileName & "<br>"
                    userPostedFile.SaveAs(filepath & "\" & Path.GetFileName(userPostedFile.FileName))
                    Span1.Text += "Location where saved: " & filepath & "\" &
                    Path.GetFileName(userPostedFile.FileName) & "<p>"
 
                    Ruta = filepath & "\" & Path.GetFileName(userPostedFile.FileName)
 
                    Dim VarDocumentoXML As XmlDocument = New XmlDocument()
                    Dim VarManager As XmlNamespaceManager = New XmlNamespaceManager(VarDocumentoXML.NameTable)
                    VarDocumentoXML.Load(Ruta)

Este codigo viene de un boton :

Xmldetalle

Primero adjuntaria el archivo por medio del boton de upload y luego lo mandaria llamar desde el boton XmlDetalle

XmlDetalle1

Pero luego me saldria este error:

xmlDetalle2

Alguna sugerencia? gracias por la atencion
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
Imágen de perfil de Oscar
Val: 65
Ha aumentado su posición en 2 puestos en Visual Basic.NET (en relación al último mes)
Gráfica de Visual Basic.NET

Subir Archivos al Servidor

Publicado por Oscar (31 intervenciones) el 30/05/2018 18:34:39
Ya lo pude solucionar tuve que crear la carpeta en el directorio:
1
Dim filepath As String = Server.MapPath("~/App_Data/UploadedFiles")
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar