0

I have a spreadsheet with some information in it that I want to copy out of out my exe into a folder of the users choosing. I'm not 100% sure how to get the path to it. I'm using costura.fody which turns it into the 1 exe file

This is my latest attempt. It errors saying it can't find these files which makes sense but I'm not sure where I should be looking for them

This is where the file is (I know it says blank but I have a bad naming conventions)

enter image description here

This is the code where I'm trying to make a copy of that file to somewhere else

static void Main(string[] args)
        {

            string pathPlace = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), @"Resources.Blank Releases sheet.xlsx");
            Console.WriteLine(pathPlace);
            File.Copy(pathPlace, @"D:\Code\Test\test.xlsx");
}

This is the output and error I get when I run it. Its found the folder where the exe is run from but thats about as good as I've gotten with it. enter image description here

Paul
  • 57
  • 7
  • Does this answer your question? [How to read embedded resource text file](https://stackoverflow.com/questions/3314140/how-to-read-embedded-resource-text-file) – Charlieface Jul 27 '22 at 23:00
  • `using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("YourResource")) using (var destFile = File.Create("YourDestPath")) { stream.CopyTo(destFile); }` – Charlieface Jul 27 '22 at 23:02
  • Yes that did indeed work, Thank you very much – Paul Aug 02 '22 at 17:34

0 Answers0