Get file using virtual path

Posted by Oswaldlily under VB.NET on 4/10/2014 | Points: 10 | Views : 1320 | Status : [Member] | Replies : 2
I have xml files in my application...Now how to get this file using virtual path in window application...

Note : [Whereas in asp.net v used Server.mappath(..)]




Responses

Posted by: Allemahesh on: 4/10/2014 [Member] [MVP] Silver | Points: 25

Up
0
Down
Try the below one:-

string _Path = System.IO.Path.GetDirectoryName(Paht) + "\\filename.xml";


Or

string _Path = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\filename.xml";

Happy coding

Oswaldlily, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: A2H on: 4/10/2014 [Member] [MVP] Silver | Points: 25

Up
0
Down
You can use the below codes

VB.Net
'Get the Path of Xml file
Dim fullPath As String = System.IO.Path.Combine(System.Environment.CurrentDirectory, "YourPath/SomeFile.ext")


C#:
 string fullPath = System.IO.Path.Combine(System.Environment.CurrentDirectory, "YourPath/SomeFile.ext");


Thanks,
A2H
My Blog

Oswaldlily, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response