Greetings to all,

I want to use the "System.IO.File.Delete(PATH);" function to delete a file that is in my Project whenever I run the app.

The problem is that in order for this to work I have to specify a full path

The problem is that this path is different from one computer to another, so this will only work on my computer.

Is there a way to specify a Default Path that would make this method work on any computer?

Thanks in advance.

Edited by 0xCMD: n/a

6 Years
Discussion Span
Last Post by Geekitygeek

Should be able to use this to do what you want...

string path;
   path = System.IO.Path.GetDirectoryName( 
      System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase );

Got that from this source. There's also a VB method there as well.

Hope this helps :) Please mark as solved once your issue is resolved.

Votes + Comments
Thanks I'll try the suggestion and reply back.

Or similarly string path = System.Reflection.Assembly.GetExecutingAssembly().Location returns the path of the file containing the exectable :)

Edited by Geekitygeek: lost code tags

Votes + Comments
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.