Help: Updateing File

  • Thread starter Thread starter old_School
  • Start date Start date
O

old_School

Guest
Making a simple sample for my self but I cant get it to download this file, keep getting error:


Imports System.IO

Public Class Form1
Private Storage As New Storage

Private Sub btn1_Click(sender As System.Object, e As System.EventArgs) Handles btn1.Click
Update File
My.Computer.Network.DownloadFile("http://www.uoksoftware.com\downloads\text.xml", Application.StartupPath)
Load Action
Dim MatchObject As Storage
Construct an instance of the XmlSerializer with the type
of object that is being deserialized.
Dim MatchSerializer As Xml.Serialization.XmlSerializer = New Xml.Serialization.XmlSerializer(GetType(Storage))
To read the file, create a FileStream.
Dim MatchFileStream As FileStream = New FileStream("text.xml", FileMode.Open)
Call the Deserialize method and cast to the object type.
MatchObject = CType(MatchSerializer.Deserialize(MatchFileStream), Storage)
MatchFileStream.Close()
rtbText.Text = Storage.strData
End Sub

Private Sub btnSave_Click(sender As System.Object, e As System.EventArgs) Handles btnSave.Click
Save Action
Dim MatchObject As Storage = New Storage()
Insert code to set properties and fields of the object.
Dim MatchSerializer As Xml.Serialization.XmlSerializer = New Xml.Serialization.XmlSerializer(GetType(Storage))
To write to a file, create a StreamWriter object.
Dim MatchWriter As StreamWriter = New StreamWriter("text.xml")
MatchSerializer.Serialize(MatchWriter, MatchObject)
MatchWriter.Close()
End Sub
End Class

Exception:

System.ArgumentException was unhandled
Message=http://www.uoksoftware.com\downloads\text.xml is not a valid remote file address. A valid address should include a protocol, a path and a file name.
Parameter name: address
ParamName=address
Source=Microsoft.VisualBasic
StackTrace:
at Microsoft.VisualBasic.Devices.Network.GetUri(String address)
at Microsoft.VisualBasic.Devices.Network.DownloadFile(String address, String destinationFileName, String userName, String password, Boolean showUI, Int32 connectionTimeout, Boolean overwrite, UICancelOption onUserCancel)
at Microsoft.VisualBasic.Devices.Network.DownloadFile(String address, String destinationFileName)
at Download_Updateable_File_Sample.Form1.btn1_Click(Object sender, EventArgs e) in c:\users\holmes\documents\visual studio 2010\Projects\Download Updateable File Sample\Download Updateable File Sample\Form1.vb:line 8
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
at Download_Updateable_File_Sample.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
InnerException:

Continue reading...
 
Back
Top