0

I am working on a project to keep all my passwords in safe. I don't want to use another file to keep the passwords, I want it to be stand-alone. Thus, on runtime (let's say when I press apply button or on FormClosing event etc...) I need to edit the resources that will be keeping encrypted passwords. Is it possible and if so how? If not possible, what are the best alternatives? Btw, I don't want to use registry either since it would kill portability.

Thanks in advance!

Edit: By resources I mean embeded ones.

Edit: After Jason's answer, I need to change the question a little bit; is there any way to write anything to a running executable itself?

gunakkoc
  • 1,069
  • 11
  • 30

1 Answers1

0

This article shows how to access an embedded resources inside an assembly using a stream. Could give you enough of a start on how to edit the passwords resource that you mention.

EDIT; Ah, even better:

How to read embedded resource text file

EDIT:

Just use a StreamWriter e.g.

using (Stream stream = Assembly.GetExecutingAssembly()
                               .GetManifestResourceStream("file1.txt"))
using (StreamWriter sw = new StreamWriter(stream))
{
    sw.Write("This is a test");
}

EDIT:

OK, looks like a dead end:

How To Read, Then Write To An Embedded Resource In C#

Embedded resources are compiled into your assembly, you can't edit them.

Community
  • 1
  • 1
Jason Evans
  • 28,906
  • 14
  • 90
  • 154
  • They don't seem to show me how to write to an embeded resource, they show only the reading part :( – gunakkoc Aug 13 '12 at 21:24
  • I tried it. It throws an exception: System.ArgumentException: Stream was not writable. – gunakkoc Aug 13 '12 at 22:01
  • Well that's sad. So I will copy paste the question in the thread you pointed :) "Do you know if there's any way to write to a resource that's part of the program without having the data in a seperate file?" – gunakkoc Aug 13 '12 at 22:14