0

I have added the file pluginsInHead.txt as the image shows..

enter image description here

My HeaderAndPlugin.cs has this code:

private void changeFile(FileInfo file)
{
    File.Replace("pluginsInHead", file.FullName);
}

When running.. It breaks with this message:

An unhandled exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll

Additional information: Could not find file 'C:\Users\washington.guedes\documents\visual studio 2015\Projects\FilesAppManager\FilesAppManager\bin\Debug\pluginsInHead.txt'.

And, it is right.. because I went to that directory and ..bin\Debug doesn't have the file.

What I did wrong?

kennyzx
  • 12,845
  • 6
  • 39
  • 83

2 Answers2

3

If you are expected pluginsInHead.txt to be in your bin\debug directory, you need to set its build action to "copy file"

  1. Select pluginsInHead.txt from solution explorer
  2. Press ALT+ENTER
  3. Change "Copy to Output Directory" to "Copy Always"
Alex
  • 952
  • 7
  • 12
1

Right-click that file name, then in its Properties Copy to Output Directory setting mark Copy Always. You can also check this SO question:

What are the various "Build action" settings in Visual Studio project properties and what do they do?

Community
  • 1
  • 1
w.b
  • 11,026
  • 5
  • 30
  • 49