XML file source from users/appdata/roaming folder

Jayme65

Active member
Joined
Apr 5, 2011
Messages
35
Programming Experience
Beginner
VB.NET:
<Window x:Class="MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="MainWindow" Height="350" Width="525">
    <Grid>
        <Grid.Resources>
            <DataTemplate x:Key="SystemTemplate">
                <Label Content="{Binding XPath=Name}"/>
            </DataTemplate>
        </Grid.Resources>
        <Grid.DataContext>
            <XmlDataProvider x:Name="SystemData" Source="Systems.xml" XPath="Emulators/System" />
        </Grid.DataContext>
        <ListBox Height="244" HorizontalAlignment="Left" Margin="12,12,0,0" Name="ListBox1" VerticalAlignment="Top" Width="167"
                 ItemsSource="{Binding}"
                 ItemTemplate="{StaticResource SystemTemplate}"
                 IsSynchronizedWithCurrentItem="True"
                 Visibility="Visible" SelectionMode="Single">
         </ListBox>
    </Grid>
</Window>

Hello,
I've bind an XML file to a ListBox.
Everything's working right..but the XML file is read as a resource for now...what I would like is being able to read it from the users/appdata/roaming folder! (that's where user's data are saved..so I would like to be able to read from there too!)
So, how should I adapt that 'Source=""' part to reference the users/appdata/roaming folder?

Hope that I'm clear! Thanks for your help!
 
str = My.Computer.FileSystem.SpecialDirectories.CurrentUserApplicationData


gets you a string like this

C:\Users\B\AppData\Roaming\WindowsApplication1\WindowsApplication1\1.0.0.0

Shouldn't be too difficult to parse what you need from it.
 
Back
Top