-1

I'm designing a script generator using winforms. Scope is to generate few update/Insert queries. I've template of update/insert queries within my project in a folder in format of .text.

text = File.ReadAllText(@"\Visual Studio 2013\Projects\MigrationScript\MigrationScript\Scripts\Schema_OWNER.SYS_PARAMS.txt");
        text = text.Replace(Constants.LOWER_VER, lowerversion)
                   .Replace(Constants.CURRENT_VER, currentversion);
        System.IO.Directory.CreateDirectory(string.Format(Constants.DIRECTORY_CCB_SEED_OWNER, releaseVal));
        File.WriteAllText(string.Format(Constants.DIRECTORY_CCBOWNER_SYS_PARAMS, releaseVal), text);

It works like charm in my machine. But when i extract the .exe and run in another machine, i'm getting error like System.IO.DirectoryNotFoundException: Could not find a part of the path

How to include external files within the project into my .exe, so that i could run in any machine?? Believe i explained my issue. If not please revert me.

Davey_31
  • 89
  • 3
  • 8
  • You could put them in a .resx file - https://msdn.microsoft.com/en-us/library/ekyft91f(v=VS.90).aspx and http://stackoverflow.com/questions/1134018/what-are-the-benefits-of-resource-resx-files – Orphid Aug 25 '16 at 05:54
  • @Orphid thanks for the link. i tried .resx and it worked across systems. – Davey_31 Aug 25 '16 at 23:27

1 Answers1

0

System.IO.DirectoryNotFoundException: Could not find a part of the path clearly states that path is not accessible from the system where your .exe is placed and being run. Make Sure Whatever path you have given should be accessible from the System's where your .exe is supposed to be executed.

Lara
  • 2,821
  • 7
  • 39
  • 72