Problem with loading XML file in VB.NET 2003

G

Guest

Hi All,

I am using VB.NET 2003 and having problems with loading an xml file. Here's
my code:

Public Sub LoadXML()
Dim xmlDoc As New Xml.XmlDocument
xmlDoc.Load("C:\Databases.xml")

'more code follows here

End Sub

When I get to the line that loads the databases.xml file, I get this error
message:

An unhandled exception of type 'System.NotSupportedException' occurred in
system.xml.dll
Additional information: FileStream was asked to open a device that was not a
file. FileStream's constructors that take a String will only work with
devices that are really files. If you need support for devices like "com1:"
or "lpt1:", then call CreateFile yourself then use the FileStream
constructors that take an OS handle as an IntPtr.

Any ideas why? the file C:\Databases.xml does exist.
 
R

rowe_newsgroups

Hi All,

I am using VB.NET 2003 and having problems with loading an xml file. Here's
my code:

Public Sub LoadXML()
Dim xmlDoc As New Xml.XmlDocument
xmlDoc.Load("C:\Databases.xml")

'more code follows here

End Sub

When I get to the line that loads the databases.xml file, I get this error
message:

An unhandled exception of type 'System.NotSupportedException' occurred in
system.xml.dll
Additional information: FileStream was asked to open a device that was not a
file. FileStream's constructors that take a String will only work with
devices that are really files. If you need support for devices like "com1:"
or "lpt1:", then call CreateFile yourself then use the FileStream
constructors that take an OS handle as an IntPtr.

Any ideas why? the file C:\Databases.xml does exist.

--
Thank you in advance.

Vergel Adriano

Any ideas why? the file C:\Databases.xml does exist.

Does it open fine with internet explorer? Also, can you load other Xml
files in this same application?

Thanks,

Seth Rowe
 
Z

zacks

Hi All,

I am using VB.NET 2003 and having problems with loading an xml file. Here's
my code:

Public Sub LoadXML()
Dim xmlDoc As New Xml.XmlDocument
xmlDoc.Load("C:\Databases.xml")

'more code follows here

End Sub

When I get to the line that loads the databases.xml file, I get this error
message:

An unhandled exception of type 'System.NotSupportedException' occurred in
system.xml.dll
Additional information: FileStream was asked to open a device that was not a
file. FileStream's constructors that take a String will only work with
devices that are really files. If you need support for devices like "com1:"
or "lpt1:", then call CreateFile yourself then use the FileStream
constructors that take an OS handle as an IntPtr.

Any ideas why? the file C:\Databases.xml does exist.

The help text says that the overloaded Load method that takes a
character string as the parameter must be a URL. I belive that is
different from a file path. At any rate, I have successfully loaded
XML files using the overloaded Load method that takes a FileStream as
the parameter. Of course, you have to initialize the FileStream to the
XML file to open first.
 
G

Guest

Thank you, Seth and zacks for your responses. I tried my code in a different
computer and it worked. I might just try re-installing the .NET framework
and Studio on the other computer and see how it goes.

Thanks again.

Vergel Adriano
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top