Register for your free account! | Forgot your password?

Go Back   elitepvpers > MMORPGs > Conquer Online 2 > CO2 Private Server
You last visited: Today at 21:27

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



[Question]Truncate/Open

Discussion on [Question]Truncate/Open within the CO2 Private Server forum part of the Conquer Online 2 category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Feb 2009
Posts: 1,765
Received Thanks: 382
[Question]Truncate/Open

if I use(To save char)
Code:
FileMode.Truncate
then
Code:
FileMode.Open
Will it make any difference?
FileMode.Truncate will replace all right?
Fish* is offline  
Old 07/19/2010, 00:43   #2
 
elite*gold: 20
Join Date: Apr 2008
Posts: 2,281
Received Thanks: 913
Truncate opens the file and truncates it till the file size is zero bytes, so yes, it replaces it all.
You only need to use Truncate, as it opens it as well.
kinshi88 is offline  
Thanks
1 User
Old 07/19/2010, 01:08   #3
 
elite*gold: 0
Join Date: Feb 2009
Posts: 1,765
Received Thanks: 382
So I should use Truncate instead.
it would be better?
Fish* is offline  
Old 07/19/2010, 01:13   #4
 
elite*gold: 20
Join Date: Apr 2008
Posts: 2,281
Received Thanks: 913
Well I'm not sure how you're doing it.

Truncate opens the file and removes the contents.
Open just opens the file.

So you decide =P
kinshi88 is offline  
Thanks
1 User
Old 07/19/2010, 01:18   #5
 
elite*gold: 0
Join Date: Feb 2009
Posts: 1,765
Received Thanks: 382
emm, this is how it looks the code:
example:
(For open)
Code:
        public static void SaveChar(string Name)
        {
            FileStream FS = new FileStream(@"C:\Conquer\Characters\" + Name + ".chr", FileMode.Open);
            BinaryWriter BW = new BinaryWriter(FS);
            BW.Write("Accname");
            BW.Write("Location");
            BW.Write("Noob");
            BW.Write("Silvers");
            BW.Flush();
            FS.Flush();
            BW.Close();
            FS.Close();
        }
For Truncate
example:
Code:
       public static void SaveChar(string Name)
        {
            FileStream FS = new FileStream(@"C:\Conquer\Characters\" + Name + ".chr", FileMode.Truncate);
            BinaryWriter BW = new BinaryWriter(FS);
            BW.Write("Accname");
            BW.Write("Location");
            BW.Write("Noob");
            BW.Write("Silvers");
            BW.Flush();
            FS.Flush();
            BW.Close();
            FS.Close();
        }
would it make any difference.
or it would be same if i use open or truncate?
Fish* is offline  
Old 07/19/2010, 03:49   #6


 
CptSky's Avatar
 
elite*gold: 0
Join Date: Jan 2008
Posts: 1,443
Received Thanks: 1,175
With 'Open', you can only edit a few bytes. With 'Truncate', you need to rewrite all the file.
CptSky is offline  
Thanks
2 Users
Old 07/19/2010, 04:21   #7
 
elite*gold: 0
Join Date: Feb 2009
Posts: 1,765
Received Thanks: 382
so if i use this for save, truncate will be best?
dats how i see it.
cuz open only change some things, truncate will change all.
I could be wrong?
Fish* is offline  
Old 07/19/2010, 10:15   #8


 
Korvacs's Avatar
 
elite*gold: 20
Join Date: Mar 2006
Posts: 6,126
Received Thanks: 2,518
Depends what your writing, if you use a filestream and you write from the start of the file you overwrite the contents anyway, so really theres no difference between the two methods, you could argue that in this case .Open would be better because you arnt having the cpu truncate the file first, but the performance gain is going to be marginal.
Korvacs is offline  
Thanks
1 User
Old 07/19/2010, 21:29   #9
 
elite*gold: 0
Join Date: Feb 2009
Posts: 1,765
Received Thanks: 382
Okay I will let it be Open ;D
Fish* is offline  
Old 07/20/2010, 12:56   #10
 
elite*gold: 0
Join Date: Nov 2009
Posts: 129
Received Thanks: 45
You should employ the using operator when working with classes that inherit the IDisposable class.

That way, when the using() block closes, all resources are freed.
~Falcon is offline  
Thanks
1 User
Old 07/21/2010, 15:39   #11
 
elite*gold: 0
Join Date: Feb 2009
Posts: 1,765
Received Thanks: 382
okay thanks
Fish* is offline  
Reply


Similar Threads Similar Threads
[question] open dragonica twice
09/20/2009 - Dragonica - 7 Replies
is there anyone to open dragonica twice? edit: im playing at dragonica EU.
[Question] cant open the Dshop :S
07/28/2009 - Dekaron Private Server - 4 Replies
WTF? i cant open the Dshop :S no error or something, just cant open =D
[Question] Can you open NPC anywhere in the map with CE?
02/01/2009 - Dekaron - 7 Replies
Hi Guys! My question is rather simple: Do any of you know if there is a way to open a NPC, for example NPC Store or Stash anywhere in the map with CE? It doesnt have to work in all maps, just in the same map where the actual NPC is located. I tried a method I used in another similar game for the same task, but at least that did not work... So, any ideas would be greatly appreciated, thanks! ~GodInDisguise
question|is there any way to open cabal twice??
05/04/2008 - Cabal Online - 6 Replies
like the title says, i want to open caba client twice.:) is there any way to do it? (on the same computer) <<----For the idiots.
[QUESTION]-WHAT DO YOU DO AFTER YOU OPEN OWNASAURUS?-
12/31/2007 - Soldier Front - 0 Replies
I have a question. When you rename Ownasaurus loader and mitch's xmas wallhack dll. to WALLHACK.DLL and WALLHACK.EXE, then you open them once its in the same folder..what do you do? I load the game then go to my inventory and press F1 and F2, nothing happens. HELP :confused::confused::confused::confused::confused :



All times are GMT +1. The time now is 21:28.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.