Results 1 to 4 of 4

Thread: Help Saving XML Data

  1. #1

    Thread Starter
    Lively Member JAtkinson's Avatar
    Join Date
    Feb 2004
    Location
    Richmond, VA
    Posts
    68

    Help Saving XML Data

    Im currently writing an XML program where you can submit information about a person through comboboxes and textboxes. Im running into problems saving the data to a certain folder.

    For Example: Creating Football Player information

    - Enter Name of Player (textbox)
    - Enter Team Name (choose from combobox)
    - Enter Position (choose from combobox)
    - etc

    I would like to save the data in a file named for the Team Name and Position Name

    Example, if the Team Name selected was "Washington Redskins" and the Position selected was "Quarterback", I would like to save the file to C:\Washington Reskins\Quarterback
    My Current Code is as follows:

    VB Code:
    1. Code:
    2. Public ReadOnly Property DataFilename() As String
    3.         Get
    4.  
    5.             Dim folderpath1 As String = cmbNewTeam.Text
    6.             Dim folderpath2 As String = cmbNewPosition.Text
    7.  
    8.  
    9.             ' get our working folder...
    10.             Dim folder As String
    11.             folder = "c:\" & folderpath1 "\" & folderpath2 "\"
    12.  
    13.  
    14.             ' return the folder with the name "Player Profile.xml"...
    15.             Return folder & "\Player Profile.xml"
    16.         End Get
    17.     End Property




    If you look at the "folder =" part, you can see what Im trying to do. I just need the correct format for doing this. I know someone out there can figure this simple problem out. Thanks!!

  2. #2
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    Wouldn't it be easier to store all the info in the same file just in different groups?

    <NFL>
    <Green Bay Packers>
    <Quarterback>
    <Player name="Bret Favre" number="4"/>
    </Quarterback>
    </Green Bay Packers>
    </NFL>

    Anyway:
    VB Code:
    1. Public Function DataFilename(ByVal team As String, ByVal position As String) As String
    2.       ' get our working folder...
    3.       Dim folder As String
    4.       folder = "c:\" & team & "\" & position
    5.  
    6.       ' return the folder with the name "Player Profile.xml"...
    7.       Return Io.Path.Combine(folder,"Player Profile.xml")
    8. End Function
    9.  
    10. 'syntax for use
    11. Msgbox(DataFileName(cmbNewTeam.Text, cmbNewPosition.Text))

  3. #3

    Thread Starter
    Lively Member JAtkinson's Avatar
    Join Date
    Feb 2004
    Location
    Richmond, VA
    Posts
    68
    You are probably right, I have only been programming (or attempting to) for 2 weeks. Thanks for the help though!!!!

  4. #4

    Thread Starter
    Lively Member JAtkinson's Avatar
    Join Date
    Feb 2004
    Location
    Richmond, VA
    Posts
    68
    Now Im getting this error:


    An unhandled exception of type 'System.IO.DirectoryNotFoundException' occurred in mscorlib.dll

    Additional information: Could not find a part of the path "c:\Buffalo Bills\QB".


    And it takes me to this line:

    VB Code:
    1. '  Open the file...
    2.         Dim stream As New FileStream(tempFilename, FileMode.Create)
    I have created this folder prior to running the application

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width