I'm creating a Windows Form application that is going to be used as a sign in system at my college. I was given a .csv file that includes student id numbers, names, teachers, and current courses. I have the app created and it works when I use it on my computer. However, when I publish the application and install it on a different computer, the streamReader that I use to access the .csv file is not able to use the .csv file because it's nowhere in the published application. I have tried adding the file to the root directory of the project, but I can't find out how to access it from there. I've read a few forums that talk about adding the file as a "resource," but I don't know enough about that to make it work for what I'm doing. Any assistance would be appreciated. Thanks!
Asked
Active
Viewed 1,392 times
-1
-
Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); Gets the current directory your executable is in. – clamchoda May 01 '15 at 15:30
-
Weird, what I understand is that you as a developer have been given access to a list of non-anonymous data. OK maybe that was dummy data for testing purposes. But then your implementation seems to require and provide that file with any app installation. Please tell me that I misunderstood something. – Yunnosch Jun 28 '22 at 19:52
1 Answers
4
In visual studio, add the file to your project (Add Existing after right click on the project). You'll need to add a build action as well, to tell the IDE to copy the file to the output directory. To do that, right click on the file you added, go to Properties, and look for BuildAction.

Mathieson
- 1,698
- 2
- 17
- 19
-
1This worked for me with the following results: Setting the Build Action property to "Content" adds the csv file into the project when you publish it. Setting the Copy to Output Directory property to "Copy always" puts the file into the Debug and Release folders. – Joseph True Sep 21 '17 at 01:47