473,698 Members | 2,751 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 5894
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**********@g mail.comwrote in message
news:11******** **************@ b28g2000cwb.goo glegroups.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.res ources");
// 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", "Concentrat e 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
2173
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
2369
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 ".txt" file directly. Thanks.in advance.
3
3063
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 information about materials, whenever I use the function that I've written to edit the info on that line I get a strange error. For example: I have the following line "tt 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0"
1
32925
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); ###Question: Now this creates finalfile.txt with ANSI Encoding ...which is a default. Either tell me how to change the default or how to create a
5
2338
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 Disallow: /account/myint ...
9
3754
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
2623
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 unknown browsers. But the Python parser doesn't see it that way. No matter what user agent or URL is specified; for that robots.txt file, the only answer is "False". It's failing in Python 2.4 on Windows and 2.5 on Fedora Core.
2
1698
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 of seats column where when i check the status of that particulat bus no 4324 it is displaying that the "seat is not available" and "available seats are 0" In this code snippet i i face the above problem in the "temp" variable. please help me out.
2
1732
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 points. These records are imported from a txt file, and never manually entered. Currently there are no forms at all. The first problem is that the txt file continually gets updated by a CAD program. The second problem is that there is one extra...
0
8674
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8603
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9157
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9026
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8893
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8861
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5860
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3045
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2328
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.