|
-
Mar 10th, 2005, 03:40 PM
#1
Thread Starter
Addicted Member
Can't seem to open XML file
xmlFileName = "c:\ghana.xml"
Dim FsXML As New FileStream(xmlFileName, FileMode.Open)
I have tried giving it all sorts of paths for file names, but It just can't find the file\ directory
stuff I've tried
xmlFileName = "ghana.xml"
xmlFileName = "\ghana.xml"
xmlFileName = "\..\ghana.xml"
I've tried putting the XML file in the solution folder, in the root C Folder and all...but I guess Im missing out on something.
thanks
Udit
-
Mar 11th, 2005, 05:29 AM
#2
Fanatic Member
Re: Can't seem to open XML file
1.first of all if your are readin and writing to XML use the XmlTextWriter and XmlTextReader classes.
2. are you trying to find the file on you device. or on a pc. if you are looking for a folder on the device its simple file.
Dim myXmlWriter As XmlTextWriter
myXmlWriter = New XmlTextWriter("\My Documents\TestFolder\myxml.xml", Nothing)
Barry
Visual Studio .NET 2008/Visual Studio .NET 2005/Visual Studio .NET 2003
.NET Framework 3.0 2.0 1.1/ASP.Net 3.0 2.0 1.1/Compact Framework 1.0
SQL Server 2005/2000/SQL Server CE 2.0
If you like, rate this post
Compact Framework for Beginners
-
Mar 11th, 2005, 03:58 PM
#3
Thread Starter
Addicted Member
Re: Can't seem to open XML file
Right Now, Im trying to run the program on the emulator. Im actually using the XMLTextReader and XMLTextWriter Classes to get data from a form and put it into an XML file..Im using this Quickstart example:
VB Code:
' Set file names and create file streams.
' The XSD, XML, and EXE must be in the same directory.
statesDS = New DataSet
xmlFileName = "\program files\databindingdemo\states.xml"
xsdFileName = "\program files\databindingdemo\states.xsd"
Dim FsXML As New FileStream(xmlFileName, FileMode.Open)
Dim FsXSD As New FileStream(xsdFileName, FileMode.Open)
' Load the schema into the DataSet.
Dim xtrXSD As New XmlTextReader(FsXSD)
statesDS.ReadXmlSchema(xtrXSD)
xtrXSD.Close()
FsXSD.Close()
' Load the data into the DataSet.
Dim xtrXML As New XmlTextReader(FsXML)
statesDS.ReadXml(xtrXML)
xtrXML.Close()
FsXML.Close()
' Get a DataTable to conveniently use for binding.
Dim dt As DataTable = statesDS.Tables("state")
'Bind the list box to state abbreviations.
lstState.DataSource = dt
lstState.DisplayMember = "abv"
'Bind the label to show the name of the state.
lblState.DataBindings.Add(New Binding("Text", dt, "name"))
'Bind the text box for entering data.
txtData.DataBindings.Add(New Binding("Text", dt, "data"))
1) firstly, why can't I hardcode a path such as c:\states.xml
2) secondly, Since I'm not deploying the solution right now, what relative path do I give....Im doing the following right now
VB Code:
Dim xtrXSD As New XmlTextReader("\My Documents\Visual Studio Projects\SmartDeviceApplication5\states.xsd")
statesDS.ReadXmlSchema(xtrXSD)
xtrXSD.Close()
I'v also tried
("\My Documents\Visual Studio Projects\SmartDeviceApplication5\bin\states.xsd")
and
("\My Documents\Visual Studio Projects\SmartDeviceApplication5\obj\states.xsd")
It still doesnt work
-
Mar 12th, 2005, 08:30 PM
#4
Fanatic Member
Re: Can't seem to open XML file
1. You realise that their is no such directory called C:\ on the device. This path only exists on PCs never on devices. Locations on devices are of the form \Programs Files\some folder or \My Documents\some folder
2. Since you are using it on the emulator you give it any of the locations available on the emulator. These folders NEED to exist before you can write to the so you need to use Directory class and the create/new method.
so example
system.io.directory.create("\My Documents\My New Folder\")
Dim xtrXSD As New XmlTextReader("\My Documents\My New Folder\states.xsd")
statesDS.ReadXmlSchema(xtrXSD)
xtrXSD.Close()
Barry
Visual Studio .NET 2008/Visual Studio .NET 2005/Visual Studio .NET 2003
.NET Framework 3.0 2.0 1.1/ASP.Net 3.0 2.0 1.1/Compact Framework 1.0
SQL Server 2005/2000/SQL Server CE 2.0
If you like, rate this post
Compact Framework for Beginners
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|