[Mono-list] how to get relative path
yossiozani at gmail.com
Mon Jan 12 05:32:30 EST 2009
First thanks for the fast reply...
I solved the problem thanks to your help.
I use option number 4, and it works fine!!!.
My Idea is that the program will perform some kind of operation accroding to
a config text file. The problem was, when I execute the program from other
users, It didn't found the correct path, (since I used Path.Getcurrentpath()
Thank for all the help
Chris Howie wrote:
> On Mon, Jan 12, 2009 at 4:55 AM, YyYo <yossiozani at gmail.com> wrote:
>> Hi all...
>> I am new to C# language and I have, probably a simple question, about how
>> get the relative path of the execution file.
>> In my solution, I have a text file with some information. In my program,
>> want to open the text file using a relative path.
>> My question is how can I get the path of the execution file, so from it I
>> could know the relative path of the text file.
>> Many thanks for the help...
> There are a few cases I can see requiring this for:
> 1. The file is a data file that will likely never change, or only
> needs to change when recompiling. In this case it would be better to
> embed the file in the compiled executable as a resource and use
> reflection to extract the stream at runtime.
> 2. The file is a configuration-type file that will probably change.
> In this case you can either do what you're doing (which I would not
> recommend) or use
> "YourAppName") to obtain a path to a directory where you can save and
> load this stuff.
> 3. The file is a data file that will be processed by the application.
> In this case you should either allow specification of the filename as
> an argument, or if you really want to only allow one filename, just
> open the file by its name and allow the environment to locate the file
> in the current working directory.
> And if you really want to approach the problem the way you are, then
> you want to "using System.IO; using System.Reflection;" and use
> Chris Howie
> Mono-list maillist - Mono-list at lists.ximian.com
View this message in context: http://www.nabble.com/how-to-get-relative-path-tp21411461p21411927.html
Sent from the Mono - General mailing list archive at Nabble.com.
More information about the Mono-list