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
"C:\Users\SomeUser\Desktop\SomeAppFolder\Content\Models\Model1.X"

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 6 Years Ago by 0xCMD: n/a

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.

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 6 Years Ago by Geekitygeek: lost code tags

Comments
Thanks.
This question has already been answered. Start a new discussion instead.