Posted on 2003-03-21
Medium Priority
Last Modified: 2010-04-15
OK, here I am again. There are two questions in one, both interrelated.
1. I have a text file containing important information. I want the user to be able to read the content of this text file only through a textbox when the application is running. I have tried changing the file extensions from .txt to .bat or .dat, etc. Although it appears to work, the contents become easily readable when I changed the file extension to .doc, .txt, or .rtf. How can I make the text unreadable except through the application? Or, is it possible to compile the textfile with the application?
I have tried encryption, but I found the process rather cumbersome. I don't want to encrypt and decrypt ad infinitum. I don't want to use a database either; a textfile is just fine for my purpose.

2. I want to use the same text file to populate a textbox in a form. The text file is saved in the same directory as my project. Since I do not know where the users of my application will install it, I did not want to hardcode the path, so I used Application.ExecutablePath. The application gave an error: can't find the file. If I used "c:\\mytextfile.txt" it works fine

Thanks everyone, for your help.

Question by:innovator2
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2

Expert Comment

ID: 8183780
What does the text file contain? Is the information constant or dynamic? If it is constant, then I would compile it into your applications or possibly compile it into a seperate library.

If the contents are dynamic you only have two choices, Obfuscation or Encryption. Obfuscation is "light" encryption which focuses on making the text not immediately obvious or hidden in a way that the user cannot easily stumble upon it. Why not use the registry to store the text? If its small that alone is probably good enough to "hide" it. You can also do some simple "encryption" on it such as modifying the value of each byte in the file by adding 5. That way all 'a's become 'e' etc. That should be enough to make any casual user not want to try to read it. You can make the filename non-obvious as well. Don't use an extension or use a non-standard one. "myfile" or "myfile.zzz".

As for your file problems, try referencing the file from ".". "." is a valid DOS directory meaning the current directory. ".\myfile.txt" for example.


Author Comment

ID: 8184281
Thanks, Bill
To the first question, the information is static. However, how do I compile it into the application? The IDE creates a bin folder, which contains my executable file. How do I instruct the IDE to add the textfile to the executable?


Accepted Solution

BillFoust earned 500 total points
ID: 8189988
I'm not sure. All of my work with C# has not been UI stuff. In C++ you would create a StringTable resource and add the text as an entry into the StringTable. Then the code to populate the text box would have another version taking the resource ID of the string.  The process should be pretty similiar in C#, though I cannot provide specifics. I'll try to find out next week and let you know.

Author Comment

ID: 8191452
Will be on the lookout.


Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

770 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