|
-
Feb 9th, 2004, 05:12 PM
#1
Thread Starter
Lively Member
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:
Code:
Public ReadOnly Property DataFilename() As String
Get
Dim folderpath1 As String = cmbNewTeam.Text
Dim folderpath2 As String = cmbNewPosition.Text
' get our working folder...
Dim folder As String
folder = "c:\" & folderpath1 "\" & folderpath2 "\"
' return the folder with the name "Player Profile.xml"...
Return folder & "\Player Profile.xml"
End Get
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!!
-
Feb 9th, 2004, 05:20 PM
#2
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:
Public Function DataFilename(ByVal team As String, ByVal position As String) As String
' get our working folder...
Dim folder As String
folder = "c:\" & team & "\" & position
' return the folder with the name "Player Profile.xml"...
Return Io.Path.Combine(folder,"Player Profile.xml")
End Function
'syntax for use
Msgbox(DataFileName(cmbNewTeam.Text, cmbNewPosition.Text))
-
Feb 9th, 2004, 05:22 PM
#3
Thread Starter
Lively Member
You are probably right, I have only been programming (or attempting to) for 2 weeks. Thanks for the help though!!!!
-
Feb 9th, 2004, 05:58 PM
#4
Thread Starter
Lively Member
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:
' Open the file...
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|