How to update a TXT resource?

Posted on 2008-02-11
Medium Priority
Last Modified: 2013-12-17
I have a text file that I have included in a Visual Studio 2005 (C#) project.

I recently updated the file in a text editor, but now, whenever I build the solution, the program somehow uses the *old* text file -- which I have confirmed is nowhere on my hard drive.

Note that I didn't change the name of the file; I simply updated its contents, which are now very different from what they were before (so there's no chance that I could be getting the same output).

So, why is my program still running as though the contents of my TXT file haven't changed??  The old file must be cached somewhere, but I can't find it.  I tried cleaning my solution, removing the re-adding the text file as a project resource, and manually deleting build files -- nothing has worked.

-- Milo
Question by:MiloDC
  • 2

Expert Comment

ID: 20869972
Try the following:

Select the file in the Solution Explorer and change the properties as follows:
- Build Action: Embedded Resource
- Copy To Output Directory: Copy if newer (or Copy Always)

This should ensure that it will leave the file as standalone as well as copy it to the output folder for the project. It should in general also include it if you create a ClickOnce installation.

Author Comment

ID: 20870389
qalar71, that didn't work.  Same result.

I wonder if my problem has something do to with the way in which I am -- or rather, am not -- specifying the TXT file in my C# code.

Currently, I refer to it simply as "myFile.txt."  Should it first be defined as some kind of resource object?

Accepted Solution

MiloDC earned 0 total points
ID: 20870446
Yeah, I'm Googling around and it looks like I need to create an Assembly object that I can use to access an embedded resource.


Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Simulator games are perfect for generating sample realistic data streams, especially for learning data analysis. It is even useful for demoing offerings such as Azure stream analytics, PowerBI etc.
Kernel Data Recovery is a renowned Data Recovery solution provider which offers wide range of softwares for both enterprise and home users with its cost-effective solutions. Let's have a quick overview of the journey and data recovery tools range he…
Enter Foreign and Special Characters Enter characters you can't find on a keyboard using its ASCII code ... and learn how to make a handy reference for yourself using Excel ~ Use these codes in any Windows application! ... whether it is a Micr…
Suggested Courses

589 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question