Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to point to a file stored in project folder? WPF

At the moment I'm pointing to a file on my machine, but I'm wondering how I would point the string to a folder I created within the project. For example the path to the folder in visual studio is,

C:\Users\Drian Darley\documents\visual studio 2013\Projects\KinectBVversion1\KinectKickboxingBVversion1\Gesture\jabtwo.xml 

I have heard of pack URI's, would that suit in this situation or how would I set one up?

This is how it is pointing to the file at present, which is not ideal as it has to point to a file stored locally on the machine.

private string gesturefile =
            Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\GesturePak\\wave.xml";
like image 818
Brian Var Avatar asked Dec 15 '22 00:12

Brian Var


1 Answers

Try like this

string gesturefile= Path.Combine(Environment.CurrentDirectory, @"GesturePak\wave.xml");

Examples:

http://msdn.microsoft.com/en-us/library/fyy7a5kt(v=vs.110).aspx http://www.dotnetperls.com/path

or

Use Path.GetFullPath

Example : http://msdn.microsoft.com/en-us/library/system.io.path.getfullpath.aspx

like image 96
NullReferenceException Avatar answered Jan 05 '23 16:01

NullReferenceException