473,327 Members | 2,090 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

How to add a ".txt" resources file

Hi there,

Does anyone know how to add ".txt" resources file to a C# project in Visual
Studio. It should compile down to an embedded ".resources" file the same way
as a ".resx" file. Thanks.
Aug 25 '06 #1
3 5861
Add the .txt file (e.g. Add -New Item...), and change the build type
to "Embedded Resource". Note you will need to write the read code.

You can also do this by adding a text file, opening e.g. the default
resx, and dragging the text file into the resx designer; this will
compile from that text file *into* the resx, allowing slightly easier
access, but with slightly higher footprint (for the resx wrapper).

Marc

Aug 25 '06 #2
"Marc Gravell" <ma**********@gmail.comwrote in message
news:11**********************@b28g2000cwb.googlegr oups.com...
Add the .txt file (e.g. Add -New Item...), and change the build type
to "Embedded Resource".
Thanks for your help. I already tried that however and all it does is add
the ".txt" file as an embedded resource. I need to compile it into a
".resources" file first however and add that file as the embedded resource.
If there's no built-in way to do this I'll manually compile it using
"resgen.exe" but I can't figure out how to do this (add the call in VS that
is). Any suggestions? Thanks.
Aug 25 '06 #3
John,
This is a very old code snippet, but it may help:

static void createResource()
{

// you could load your text file here and use that----
//using ResourceWriter allows us to write to binary *.resources files
ResourceWriter rw =new ResourceWriter("MyMessages.resources");
// add our string resources with name, value
rw.AddResource("1", "Signs point to yes.");
rw.AddResource("2", "Yes.");
rw.AddResource("3", "Reply hazy, try again. ");
rw.AddResource("4", "Without a doubt. ");
rw.AddResource("5", "My sources say no. ");
rw.AddResource("6", "As I see it, yes. ");
rw.AddResource("7", "You may rely on it.");
rw.AddResource("8", "Concentrate and ask again. ");
rw.AddResource("9", "Outlook not so good. ");
rw.AddResource("10", "It is decidedly so. ");
rw.AddResource("11", "Better not tell you now.");
rw.AddResource("12", "Very doubtful. ");
rw.AddResource("13", "Yes - definitely. ");
rw.AddResource("14", "It is certain.");
rw.AddResource("15", "Cannot predict now.");
rw.AddResource("16", "Most likely.");
rw.AddResource("17", "Ask again later.");
rw.AddResource("18", "My reply is no.");
rw.AddResource("19", "Outlook good.");
rw.AddResource("20", "Don't count on it.");
rw.AddResource("21", "Ask again later");
rw.AddResource("22", "Ask more later");
rw.AddResource("23", "Reply meainingless, ask again later");
rw.AddResource("24", "Should not predict now");
rw.AddResource("25", "More information later");
rw.AddResource("26", "Out to Lunch");
rw.AddResource("27", "Closed on Sundays");
rw.AddResource("28", "No chance in Hell");
rw.AddResource("29", "Do you have capslock on?");
rw.AddResource("30", "Did you log on to the domain?");
rw.AddResource("31", "What mail server are you using?");
rw.AddResource("32", "Have you tried rebooting?");
rw.AddResource("33", "Can you ping that server?");
rw.AddResource("34", "Is it plugged in?");
rw.AddResource("35", "Is the network light on at all?");
rw.AddResource("36", "What's your port number?");
rw.AddResource("37", "Did you leave your PC unlocked?");
//generate the resource
rw.Generate();
//close the resource file
rw.Close();
}
}

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"John Torville" wrote:
Hi there,

Does anyone know how to add ".txt" resources file to a C# project in Visual
Studio. It should compile down to an embedded ".resources" file the same way
as a ".resx" file. Thanks.
Aug 25 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: mike | last post by:
regards: How to add a string "XXXXXXXXXXXX" in front of a txt file?....@@ thank you may god be with you
1
by: John Layton | last post by:
Hi there, Does anyone know if there's a built-in way to read a ".txt" based resources file (one that's converted to a ".resources" file by "resgen.exe" at build time). I need to read/write the...
3
by: zbenta | last post by:
Hi you guys. I need some help with a program I've written. I can not seam to find the reason for the error that ocurrs. But let me explain. I have a txt file that works as a database to store...
1
by: ujjwaltrivedi | last post by:
Hey guys, Can anyone tell me how to create a text file with Unicode Encoding. In am using FileStream Finalfile = new FileStream("finalfile.txt", FileMode.Append, FileAccess.Write); ...
5
by: John Nagle | last post by:
Python's "robots.txt" file parser may be misinterpreting a special case. Given a robots.txt file like this: User-agent: * Disallow: // Disallow: /account/registration Disallow: /account/mypro...
9
shrek123
by: shrek123 | last post by:
How to write to a ".txt" file present on remote machine. I dont want to use two way socket connection. Is there any other way to write to a file on remote machine? Best Regards, Shrek.
2
by: John Nagle | last post by:
For some reason, Python's parser for "robots.txt" files doesn't like Wikipedia's "robots.txt" file: False The Wikipedia robots.txt file passes robots.txt validation, and it doesn't disallow...
2
by: ishakarthika | last post by:
i have a .txt file which contains line of string like the below format |111|34 sdddd| ppppp| A/C| 32| sadfd| |4324|23 mmm| yyyyy| A/C|32| fdfffdfd| the sixth column is the no...
2
tdw
by: tdw | last post by:
Hi all, I have several ideas on how to do this, but am having difficulty putting the ideas together and figuring out the most efficient way to do this. I have a database of survey coordinate...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.