Use a variable in C# path -
i need save .xml file in specific location on computer. location changed based on selection of user.
i can user selection (from combobox) variable this:
location = (string)combobox1.selecteditem;
but can’t use following command store file because of “%location%” part. says “could not find part of path”
docsave.save(@"c:\...\...\%location%\...\information.xml");
can me regarding that….?
thank you.
you should use path
class when you're working paths, if want working path multiple parts, use path.combine
:
string location = (string)combobox1.selecteditem; string dir = "c:\dir1\dir2\%location%\dir4".replace("%location%", location); string filename = "information.xml"; string fullpath = path.combine(dir, filename);