|
I need some help with a project im making it is pretty much a file archive system. It has the files in a single text file the file data is enclosed inside a head and a foot to identify it. which looks like this:
##:START:(FILENAME):(FILEDESTINATION):(FILESIZE):##
<CONTENT OF FILE HERE>
##:END--:(FILENAME):(FILEDESTINATION):(FILESIZE):##
the unpacker looks through the files and reads that data between the head and the foot and writes it into the destination directory it works for plain text files fine but when it comes to Executables the extracted file doesnt run and it has no icon anymore. Im using Encoding.Default to read and write all the data. Is there something im missing i think its possibly that the Encoding isn't quite right. When i open the exe in notepad and click save as it says its ANSI but that doesnt exist as a encoding type in Encoding.* would this be the problem?
|
|
|
|
|
fuze wrote: Im using Encoding.Default to read and write all the data.
Then you're not using the proper file methods to reading and writing binary data. You're treating everything as a text file, even the executables. You should be using the Binary Reader/Writer.
|
|
|
|
|
hi
i have wcf service host
and i keep all my clients callback in a list
is it possible to send this call back to one client so he will use the other client callback function
|
|
|
|
|
I want to know a serious problem: in my searches about storing data I find that I can store it in : XML Schema, or databases: SQLite, or any other db etc.
I want to store some int 's into a XMLS to be able to use them after I restarted the app.
My actual problem is: It is possible to store inside the actual app?
I don't want to store outside that app,in some sort of file.
thx.
OR a better question: How to store some data INSIDE running app, and then after restarting that app, the data remain there and be accessible ?
|
|
|
|
|
No, a running app cannot modify its code files (EXE, DLL); they are all locked as long as the app runs, so you can't rename, delete, or modify them.
Luc Pattyn [Forum Guidelines] [My Articles]
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
|
|
|
|
True on the surface, but using shadow copies of the assemblies does allow them to be modified while running. AppDomain and Shadow Copy[^]
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
You can use the app.config file to store values or the settings file[^]
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
or any other file for that matter.
Luc Pattyn [Forum Guidelines] [My Articles]
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
|
|
|
|
yeee I find it and it does a great job indeed.
ha. I must now find a way to integrate an array there.
Here is How To Save Inside Your App !
1. select a button in the designer, open Properties for it, and see the first property named "ApplicationSettings". Click on the + sign to open his sub-properties. At the "text" property click the down arrow and it appear a little box-window. There inside click on the "(New...)".
2. At this stage, you should see a window named "New Application Setting". Change the name to "mySetting", Scope = User, Default Value = "aha". Click Ok.
3. (optional) To verify if all is how you want to be, open Solution Explorer - Properties-Settings.settings. A new window appear and open the Settings tab from the left. You will see there all your custom settings.
A little advice: select the button in the designer, go to it's properties again, and at it's Name property verify if it has the "aha" value there. It must be there, because you set it in the Default Value, last time.
4. In the code for that button, write this:
private void buttonSave_Click(object sender, EventArgs e)
{
if (buttonRestore.Text == "aha" )
{
buttonRestore.Text = "-!aha!-";
}
else
{
buttonRestore.Text = "aha";
}
Properties.Settings.Default.Save();
}
5. Run your app, click the button to change it's appearance, and restart app.
VOILA!
|
|
|
|
|
I think I find a BUG for this "ApplicationSettings".
It's about after I compile the program.
If I move the myprogram.exe on another folder or partition, the values that I originally stored, they disappear.
It only retain the information data if is Not moved.
WHERE THAT DATA GO, AFTER ALL?
Is inside it, really?
Or is somewhere stored in some temp file?
thanks.
|
|
|
|
|
If you look at the documentation for "Properties.Settings.Default" you will find it is saved in a file called "<yourappname>.exe.config" in the same directory as the application executable (i.e. ".../bin/debug" or ".../bin/release") If you copy this file when you copy your executable, you will be fine. The only other option is to store it in the registry, but this is not recommended:
1) Registry use is being discouraged, as it make it too big and cumbersome.
2) It is difficult to move your settings from one machine to another.
3) It is impossible to transparently have different settings for debug and release versions of your software.
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
"Rumour has it that if you play Microsoft CDs backwards you will hear Satanic messages.Worse still, is that if you play them forwards they will install Windows"
|
|
|
|
|
I am using Visual Studio Express Edition 2008 and want to use a timer from "System.Timers".
I don't know how to create the Event without any 'Tick'-Event when the timer interval elapses.
There is no 'Tick' event in the timers-pull down menu as described in different manuals and forums.
There is one example on
C-SharpCorner
timer1.Interval = 5000;
timer1.Enabled = true;
timer1.Tick += new System.EventHandler (OnTimerEvent);
So how can I create a method, that's been processed when the interval elapsed ?
|
|
|
|
|
There are several Timer classes in .NET and each of them has a different set of properties and events.
That article is about System.Windows.Forms.Timer, which are very good for supporting periodic GUI updates, such as a clock display.
Luc Pattyn [Forum Guidelines] [My Articles]
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
|
|
|
|
Yes, in the meantime I found something about the different timers.
Since I don't use Windows.Forms, but XNA, I guess I rather should use System.Threading-timer, right ?
Is there any example for those timers ?
|
|
|
|
|
yes
yes
Google!
Luc Pattyn [Forum Guidelines] [My Articles]
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
|
|
|
|
OK, thanks !
Good night.
|
|
|
|
|
The System.Timers.Timer class has an Elapsed event instead of a Tick event.
timer1.Elapsed += new System.Timers.ElapsedEventHandler(Timer1_Elapsed);
void Timer1_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
}
|
|
|
|
|
OK, in principle that works. Thanks !
Now I have to work on the threading problem I got within my application...
|
|
|
|
|
I'm developing a chat server and a chat client in C#.
My client application is a GUI with some TabControls, ListBoxes, Buttons, Textboxes and Labels. The client also has a separate thread to detect messages sent from the server.
One of the messages sent from the server is to display what other users are available to chat with.
I can receive the other users IP-address and store them in a collection. When this is done I send an event from the thread method to the Client's GUI's Form-class and run a method to display the users.
That method is just clearing all items in a ListBox and insert all IP-addresses into the ListBox by foreach-looping the collection sent as a parameter from the event.
When I try this an: InvalidOperationException is thrown. The exception messages basically says this (translated from Swedish):
"The actions between threads are not valid. The control lstOtherUsers (the name of the ListBox) are received from an other thread that it was created in"
I can understand the problem why I cannot update the Item collection in my ListBox from an other thread when the ListBox was created in an other thread. But how shall I solve this?
|
|
|
|
|
What your experiencing is called Invalid cross-thread operations.
You can read more about it here
|
|
|
|
|
|
Hi,
Here[^] are my recommendations.
Luc Pattyn [Forum Guidelines] [My Articles]
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
|
|
|
|
|
Controls can only be accessed from the thread they were created in. To access controls from other threads, use InvokeRequired property and Invoke method:
delegate void AddListItemCallback(ListViewItem item);
private void AddListItem(ListViewItem item)
{
if (this.ListView1.InvokeRequired) {
AddListItemCallback cb = new AddListItemCallback(AddListItem);
this.ListView1.Invoke(cb, new object[] { item } );
} else {
this.Items.Add(item);
}
}
InvokeRequired returns false if the calling thread is the same thread as the one the control was created in, and true otherwise.
|
|
|
|
|
I'm having trouble creating a query that only takes a specific number of players from each position.
My goal is to create a query that takes all offensive positions by OVR (and certain number of players at each position), add up their OVR (a player property) and divide it by the number of players that I took the OVR from (to obtain the average rating). So, basically, I'm trying to obtain the average rating of all "starters" on offense. These starters are determined by their OVR rating (where the highest OVR is a starter) as well as the number I'd assign to each position to determine how many starters are at each position (so the player with the second highest OVR is another starter).
This is the code I've come up with so far:
[code]
public int OffenseRatingCalc
{
get
{
var offense = from p in Players
where p.position == PlayerPosition.QB ||
p.position == PlayerPosition.RB ||
p.position == PlayerPosition.WR ||
p.position == PlayerPosition.TE ||
p.position == PlayerPosition.LT ||
p.position == PlayerPosition.LG ||
p.position == PlayerPosition.C ||
p.position == PlayerPosition.RG ||
p.position == PlayerPosition.RT
orderby p.position
select p;
var oR = offense.Average((p) => p.OVR);
OffenseRating = Convert.ToInt32(oR);
return OffenseRating;
}
}
[/code]
The player property "position" is a PlayerPosition type--an enum that contains the following:
[code]
public enum PlayerPosition { QB, RB, WR, TE, LT, LG, C, RG, RT, DE, DT, OLB, MLB, CB, FS, SS } [/code]
OVR is also a property of the Player class.
Right now, the code works but it takes all players from each position on offense. How do I take only a specific number of players from each position (for example, 1 from QB and 2 from WR) to only be included in finding the average? So, the highest OVR at QB is chosen, and the two players with the highest OVR at WR are chosen.
|
|
|
|
|
how can a make video clip in c# like the clip that can be made in flash????????????????
|
|
|
|