Solved

WINDOWS PHONE 8.1 DEVELOPMENT Open File failure

Posted on 2014-10-20
6
508 Views
Last Modified: 2014-12-07
Hi all,
I'm trying t open an XML file in WP8.1 dev environment (VS2013).
I can open an xml file that has been added to my project.  great for testing....
I am creating a simple xml, hard coding the file, first on the phone than trying to open it.  I keep getting errors that it can't open the file.  Don't know what i'm missing here.

An exception of type 'System.Xml.XmlException' occurred in SYSTEM.XML.NI.DLL but was not handled in user code

Additional information: Cannot open 'file:///C:/Data/SharedData/PhoneTools/AppxLayouts/9366RuSoftInformationTech.RuSafeVS.Debug_AnyCPU.John/RuSafe/RuSafe 102.xml'. The Uri parameter must be a file system relative path.

Open in new window

0
Comment
Question by:Thunder724
  • 3
  • 2
6 Comments
 
LVL 16

Expert Comment

by:Kamal Khaleefa
ID: 40394167
MAKE SURE THE PATH IS CORRECT
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 40394600
I believe that the key is in this statement, "The Uri parameter must be a file system relative path.", since you have a full path.

How are you reading the file?
0
 
LVL 4

Author Comment

by:Thunder724
ID: 40394771
This is just odd...
What I'm doing is creating an XML File under a subdirectory, such as \sub.
The file(s) are created just fine and they are presented on my phone screen so that I can select them.

The path is the same location as the files.
Not the RSCatalog_Active$ variable is the actual file name.

Dim local As StorageFolder = PARENT_PATH
        Dim dataFolder = Await local.GetFolderAsync("Sub")
        'Dim RC_Catalog As StorageFile = dataFolder.GetFileAsync(RSCatalog_Active$)
        FullFilePath$ = dataFolder.Path & "\" & RSCatalog_Active$ 'RC_Catalog.Path
       
        ReadXMLData_MAIN(FullFilePath$)

Open in new window


the function to read in the XML is below.  If I have an xml file hard coded, within my project, which I've used for testing it works.

Friend Sub ReadXMLData_MAIN(ByVal XMLFileName$)
        Dim xmlData As XDocument = XDocument.Load(XMLFileName$)
        Table_Main = From query In xmlData.Descendants("MAINTBL") Select New DATA_MAIN() With _
        { _
            .sITEM_NAME = DirectCast(query.Element("sITEM_NAME").Value, String), _
            .SID = DirectCast(query.Element("SID").Value, String) _
        }

    End Sub

Open in new window


the error occurs at the point in the function....
 Dim xmlData As XDocument = XDocument.Load(XMLFileName$)

But again I know the function is ok because it can read the xml file within my project.
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 96

Expert Comment

by:Bob Learned
ID: 40397242
I would think that files within your project would have the correct relative path name.  Files outside would need a different approach.

Example #1:

Full path = C:\folder1\folder1.1\folder1.1.1\log.txt
Root = C:\folder1\folder1.1
Relative = folder1.1.1\log.txt

Example #2

Files:
C:\folder1\folder1.1\folder1.1.1\log.txt
C:\folder2\folder2.1\folder2.1.1\log.txt
C:\folder3\folder3.1\folder3.1.1\log.txt

Full path = C:\folder3\folder3.1\folder3.1.1\log.txt
Root = C:\folder1\folder1.1
Relative = ..\..\folder3.1\folder3.1.1\log.txt
0
 
LVL 4

Accepted Solution

by:
Thunder724 earned 0 total points
ID: 40476876
Sorry for the delay; I thought I had already commented on this but guess i missed this one.
I figured out the problem and it had to do witht he "\" in the path needed to be "/" the opposite direction.
0
 
LVL 4

Author Closing Comment

by:Thunder724
ID: 40485300
I figured this out on my own.
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now