|
hi, it's possible to include files such ini and dll into a exe as resource???
thanks
Paolo
|
|
|
|
|
You can include every file as a resource, and read it with manifest stream:
Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(namespace.filename.ini);
|
|
|
|
|
sorry for this stupid question.....and for adding a resource? in VS C++ 6.0 that wass add resource.....here where I found? thanks
|
|
|
|
|
In VS.NET it is
- project's context menu
- add existing element
- choose the file
- the file appears in the project tree
- file's context menu
- properties
- build action = embedded resource
The menu titles can be different in your visual studio, because I have only the german version
|
|
|
|
|
|
I'm not able to write the Assembly stream to file, I've done so
<br />
private void ExtractDLL()<br />
{<br />
<br />
try<br />
{<br />
FileStream sf = new FileStream("config.ini",FileMode.Create);<br />
StreamWriter sw = new StreamWriter(sf);<br />
Stream prova = Assembly.GetExecutingAssembly().GetManifestResourceStream("config.ini");<br />
<br />
sw.Write(prova);<br />
}<br />
<br />
catch (IOException e)<br />
{<br />
MessageBox.Show("Error while accessing to resources -> " + e.Message);<br />
return;<br />
}<br />
}<br />
but I get a 0 byte file.... where I'm wrong??? thanks
Paolo
|
|
|
|
|
You must include the full qualified path of the ressource. The ressource is a part of your assembly, so the namespace belongs to its name:
<br />
Stream prova = Assembly.GetExecutingAssembly().GetManifestResourceStream("yourNamespace.config.ini");<br />
|
|
|
|
|
I'm trying to do this;
I ask;
Console.Writeline("Enter Amount");
Then I enter something like 500.10
and then I get a return value of;
"Five hundred dollars and ten cents"
What is the easiest way to do this?
Thank you for any help..
Karie
karie4@comcast.net
|
|
|
|
|
Hi Karie,
Using simple logic you can generate the desired result. I am not aware of any ready made class and function in .Net, especially dedicated for this sort of problem.
Regards,
Jay.
|
|
|
|
|
Sounds like homework to me!
RageInTheMachine9532
|
|
|
|
|
2.ToString() Shame on you!
KTB wrote that
|
|
|
|
|
A word map and simple subtraction would do, but I agree with Dave that this sounds like homework.
You can get some help, though. See my article, Custom String Formatting in .NET[^], for an example that does something similar to what you need to convert numbers to Roman numerals.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi,
I'm going to add "Undo" "Redo" function for my project. But I really have no idea to do such things.
Is there any examples for this? Could anyone provide some for me??
Thanks a lot
|
|
|
|
|
You have two options
1. Brute force. Fill memory with copies of your document
2. Build a list of operations performed, and walk through them, changing the state of your document as you go.
What sort of document is it ?
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Actually, the undo-redo option is use for UI changing.
e.g. wrong deleting in listview item,
wrong arranging in listview,
wrong setting of my customer object, position etc...
this is quite a wide range I need to record, looks complex to do this...
|
|
|
|
|
azusakt wrote:
this is quite a wide range I need to record, looks complex to do this...
Yeah, it sounds like you need to build a class heirarchy to do it.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
So, do you know where can I find a good example ?
I really have no idea how to do this ~
Christian Graus wrote:
Yeah, it sounds like you need to build a class heirarchy to do it.
what will the class do ?? can anyone help?
|
|
|
|
|
Examples probably exist on the web, but I don't know of any. I did this years ago, for a paint program. I think we stored small bitmaps that represented the section of the image that was changed, along with a position to draw them back.
azusakt wrote:
what will the class do ??
If there's a wide variety of changes to be done, each class will be able to perform the modifications needed to undo one action. I'd imagine they might use the visitor pattern ? I'd imagine a base class, then a derived class at least for each type of object that can have an undo done on it.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Undo can be done using the Memento pattern. U can get help on this pattern from the internet. Maybe some examples too
« Superman »
|
|
|
|
|
Another couple options - one of which is common - is for each command (which Christian was probably referring to) to store how it undoes itself and then use a linked-list to store each command along with state information.
Another example uses memory protection faults to your advantage. See Undo and Redo the "Easy" Way[^], which also includes links to several other articles that discuss other methods, some of which Christian mentioned.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
What trouble am I gonna get into trying to convert C# code to FORTRAN 95 Code? DOes anyone have a solution to any known issues? Is there a .NET solution?
Jack Connolly
|
|
|
|
|
Is there a .Net Fortran 95 compiler?
|
|
|
|
|
You'll probably have some problems trying to convert .NET Framework classes to FORTRAN.
I don't know of any examples of this being done. But like the other posted said, look for a FORTRAN.NET solution. Fujitsu and Lahey are trying to get a .NET version of FORTRAN together.
RageInTheMachine9532
|
|
|
|
|
I am trying to write a crude version of c#.The fn. looks like this:
static void sscanf(string input, string format, params object[] paramlist)
{
string pattern = @"\b\S+\b";
MatchCollection matches1 = Regex.Matches(input, pattern);
MatchCollection matches2 = Regex.Matches(format, @"\b\S+\b");
for(int i = 0; i < matches1.Count; i++)
{
if (matches2[i].Value == "s")
paramlist[i] = matches1[i].Value;
else if (matches2[i].Value == "d")
{
try
{
int ii = int.Parse(matches1[i].Value);
paramlist[i] = ii;
}
catch (Exception exc)
{
Console.WriteLine(exc.Message);
}
}
else if (matches2[i].Value == "f" || matches2[i].Value == "lf")
{
try
{
double dd = double.Parse(matches1[i].Value);
paramlist[i] = dd;
}
catch (Exception exc)
{
Console.WriteLine(exc.Message);
}
}
}
}
and can be called for example as:
sscanf(str, "%s %s %lf %lf %d", os1, os2, od1, od2, oi1);
The problem I am facing is that the variables are being passed by value not by reference. Can anyone please help me? the c# compiler does not allow me to use the keyword ref in conjunction with params.
The cause of the problem - It seems to me is that object is not a reference type. This is how I tested:
say we have a fn. fn1 like:
static void fn1(object obj)
{
int i = 10;
obj = i;
}
now in main:
int i = 0;
object obj = new object();
obj = i;
fn1();
i = (int) obj;
i remains as 0 instead of 10.
pl. mail me at fd97207 yahoo if you know the answer.
|
|
|
|
|
String formatting like this is already supported in the .NET Framework. See my article, Custom String Formatting in .NET[^], for reasons why it is much better (also see the message board at the bottom) and ways to use methods like String.Format , Console.WriteLine (any TextWriter.WriteLine , actually), and StringBuilder.AppendFormat , as well as IFormattable implementations' ToString(String, IFormatProvider) methods.
The problem here, though, is that you're passing value types which are pass by value unless you use the ref keyword when passing them and in your method declaration. Since you're passing them in an array, you can't do this, though. They really don't need to be passed by reference, though - you're not changing them. Value types are allocated on the stack instead of the heap because it's more efficient (among other reasons, which are discussed throughout the .NET Framework SDK documentation and online).
Microsoft MVP, Visual C#
My Articles
|
|
|
|