Erwin Pombett
asked on
how to recover all uri but the filename ?
hello experts,
i have an Uri object that i'd like to use in order to create a new file.
i'd like to change the last info in the Uri in order to keep the path.
is there an easy way to achieve this ?
example:
Uri test = new Uri(@"c:\path\to\the\file. txt"); // 1. i have an Uri.
ChangeFile(test, "otherFile.txt") // 2. change the file for the same uri
Uri test -> c:\path\to\the\otherFile.t xt // 3. now my uri is changed.
thank you in advance.
i have an Uri object that i'd like to use in order to create a new file.
i'd like to change the last info in the Uri in order to keep the path.
is there an easy way to achieve this ?
example:
Uri test = new Uri(@"c:\path\to\the\file.
ChangeFile(test, "otherFile.txt") // 2. change the file for the same uri
Uri test -> c:\path\to\the\otherFile.t
thank you in advance.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
or the c# version seeing as we are in the c# section
Its better to use the .net path library than to guess the structure will adhere to a predicted format and use string functions
string folder = System.IO.Path.GetDirector yName("old path");
string filename = System.IO.Path.GetFileName ("old path");
string NewFilename = "predicate" + filename;
string newlocation = System.IO.Path.Combine(fol der, "new filename");
happy coding :-)
Its better to use the .net path library than to guess the structure will adhere to a predicted format and use string functions
string folder = System.IO.Path.GetDirector
string filename = System.IO.Path.GetFileName
string NewFilename = "predicate" + filename;
string newlocation = System.IO.Path.Combine(fol
happy coding :-)
I'm making mistakes all over the place today
this could of course be condensed into a one liner
string folder = System.IO.Path.GetDirectoryName("old path");
string filename = System.IO.Path.GetFileName("old path");
string NewFilename = "predicate" + filename;
string newlocation = System.IO.Path.Combine(folder, NewFilename );
this could of course be condensed into a one liner
string NewURI = System.IO.Path.Combine(System.IO.Path.GetDirectoryName("old path"), "predicate" + System.IO.Path.GetFileName("old path"));
ASKER
thank you a lot experts ;o)
Andre412: no worries for the typos ;o)
toshi_
Andre412: no worries for the typos ;o)
toshi_
Open in new window