Register for your free account! | Forgot your password?

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

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

Advertisement



The process cannot access the file ...

Discussion on The process cannot access the file ... within the CO2 Private Server forum part of the Conquer Online 2 category.

Reply
 
Old   #1
 
FromHell2Kill's Avatar
 
elite*gold: 0
Join Date: Mar 2011
Posts: 40
Received Thanks: 2
The process cannot access the file ...

While i'm using the source and testing i have got a console Error tells me that :

The process cannot access the file 'D:\Games\ConquerSource\MINE\AboDiab\5936\bin\Debu g\database\Jianghu.txt' because it's being used by another process.

And it gives me some information like :
Jianghu.cs line 147
Write.cs line 54

But i had ignored this console error.

Unfortunately, When i left the source running for about an hour .. the server stopped and gives me that error.



How can i solve this annoying problem?
Attached Images
File Type: jpg Untitled.jpg (25.3 KB, 9 views)
FromHell2Kill is offline  
Old 09/05/2014, 18:43   #2


 
CptSky's Avatar
 
elite*gold: 0
Join Date: Jan 2008
Posts: 1,434
Received Thanks: 1,146
Mhm...

So you write an empty string to a file, instead of creating it directly. Than, you truncate it and close it ? Than, you write data to it ? Honestly, your code is totally wrong. If you want to overwrite the file, just open it in write mode instead of append. All that can be done with a single stream.

Anyway, I suppose that another process is already locking the file, or that File.WriteAllText is not releasing the handle directly after writing the data.
CptSky is offline  
Old 09/05/2014, 19:08   #3
 
nTL3fTy's Avatar
 
elite*gold: 0
Join Date: Jun 2005
Posts: 692
Received Thanks: 353
If you can't even use the File class properly, why are you trying to run a server...
nTL3fTy is offline  
Thanks
2 Users
Old 09/05/2014, 19:18   #4
 
FromHell2Kill's Avatar
 
elite*gold: 0
Join Date: Mar 2011
Posts: 40
Received Thanks: 2
@CptSky --> Well, how can i write that code in the standard way?

Or specifically, How can i repair this problem?

i tried alot and already copied the Jianghu.txt from another source then a pasted it to mine, i got the same error!!!

I respect you somehow ^_^.

_________________________________
@nTL3fTy --> Firstly, it's not a published server. Just a local one for me, Just practicing on it.

Secondly, not even your business.
FromHell2Kill is offline  
Old 09/05/2014, 19:44   #5
 
nTL3fTy's Avatar
 
elite*gold: 0
Join Date: Jun 2005
Posts: 692
Received Thanks: 353
That little piece of code seems to use 3 file streams to do something you could achieve with one line of code (and one stream) -- already explained by CptSky. If you can't even work with the basic libraries provided to you with full documentation in C#, how do you plan on working on a server with little to no documentation?
nTL3fTy is offline  
Thanks
1 User
Old 09/05/2014, 19:51   #6
 
FromHell2Kill's Avatar
 
elite*gold: 0
Join Date: Mar 2011
Posts: 40
Received Thanks: 2
@nTL3fTy

Thanks for your note ^_^
FromHell2Kill is offline  
Old 09/05/2014, 20:03   #7
 
iliveoncaffiene's Avatar
 
elite*gold: 0
Join Date: Oct 2005
Posts: 332
Received Thanks: 69
Quote:
Originally Posted by FromHell2Kill View Post
@CptSky --> Well, how can i write that code in the standard way?

Or specifically, How can i repair this problem?

i tried alot and already copied the Jianghu.txt from another source then a pasted it to mine, i got the same error!!!

I respect you somehow ^_^.

_________________________________
@nTL3fTy --> Firstly, it's not a published server. Just a local one for me, Just practicing on it.

Secondly, not even your business.
Firstly, some variable names look like what you get when you use ILSpy.
'writer2' isn't even used, did you code this?
You compare bool == bool, and it isn't even File.Exists == true, you define a variable for it (another bad sign of ILSpy).
When using 'using', you shouldn't need to dispose of or close your writers, that's the point of 'using'.

Here is literally all of that in many less lines:
Code:
            if (mod == Conquer_Online_Server.Database.Mode.Open)
            {
                if (File.Exists(this.location))
                {
                    using (var writer = File.OpenWrite(this.location))
                    {
                        writer.WriteLine("Count={0}", this.Count);
                        foreach (var it in this.Items)
                            writer.WriteLine(it);
                    }
                }

                // whatever else you have here....
            }
iliveoncaffiene is offline  
Thanks
1 User
Old 09/05/2014, 23:02   #8
 
abdoumatrix's Avatar
 
elite*gold: 0
Join Date: Jul 2008
Posts: 874
Received Thanks: 239
this might be better


--------------------------

the problem is that ur source save the whole jiang client every entity close.

u need only one save on exit


check the code all reference and u will see
abdoumatrix is offline  
Old 09/06/2014, 01:12   #9
 
iliveoncaffiene's Avatar
 
elite*gold: 0
Join Date: Oct 2005
Posts: 332
Received Thanks: 69
Quote:
Originally Posted by abdoumatrix View Post
this might be better


--------------------------

the problem is that ur source save the whole jiang client every entity close.

u need only one save on exit


check the code all reference and u will see
You do realize the point of "using" don't you?! It's to auto initialize and dispose of a disposable object - that includes a StreamWriter. ".Close()" does not need to be called, the end of the "using" block does that automatically.
Also, assuming Items is an array, you should use foreach since you are not using the indexes for anything.
Also, you could condense it more and do:
Code:
using (var SW = (mod == Mode.Open ? new StreamWriter(location, false, Encoding.Default) : 
new StreamWriter(File.Create(location))))
and just have 1 loop. Eliminates so many lines of repeated code
iliveoncaffiene is offline  
Old 09/06/2014, 19:58   #10
 
elite*gold: 67
Join Date: Aug 2014
Posts: 1,321
Received Thanks: 927
Quote:
Originally Posted by iliveoncaffiene View Post
You do realize the point of "using" don't you?! It's to auto initialize and dispose of a disposable object - that includes a StreamWriter. ".Close()" does not need to be called, the end of the "using" block does that automatically.
Also, assuming Items is an array, you should use foreach since you are not using the indexes for anything.
Also, you could condense it more and do:
Code:
using (var SW = (mod == Mode.Open ? new StreamWriter(location, false, Encoding.Default) : 
new StreamWriter(File.Create(location))))
and just have 1 loop. Eliminates so many lines of repeated code
Eliminates readability too imo.
Xio. is offline  
Thanks
1 User
Old 09/06/2014, 20:06   #11
 
Spirited's Avatar
 
elite*gold: 12
Join Date: Jul 2011
Posts: 8,205
Received Thanks: 4,107
Edit: Nevermind, I read the code again for what it does, and the style is ... alright. Completely unnecessary though. Not bad style too much, just bad programming.
Spirited is offline  
Old 09/06/2014, 20:16   #12
 
abdoumatrix's Avatar
 
elite*gold: 0
Join Date: Jul 2008
Posts: 874
Received Thanks: 239
Quote:
Originally Posted by iliveoncaffiene View Post
You do realize the point of "using" don't you?! It's to auto initialize and dispose of a disposable object - that includes a StreamWriter. ".Close()" does not need to be called, the end of the "using" block does that automatically.
Also, assuming Items is an array, you should use foreach since you are not using the indexes for anything.
Also, you could condense it more and do:
Code:
using (var SW = (mod == Mode.Open ? new StreamWriter(location, false, Encoding.Default) : 
new StreamWriter(File.Create(location))))
and just have 1 loop. Eliminates so many lines of repeated code
aha i know
just edited the worst part and forget the rest.

anyway as said before

the problem isn't from here.

he had to check all the reference that use this

he will find it in a loop when i should recall only 1 time

Quote:
Originally Posted by Spirited View Post
I agree with Yuki. Putting a bunch of equals on one line is really bad style. Try to avoid it at all costs. Line count isn't everything.
abdoumatrix is offline  
Old 09/06/2014, 20:23   #13
 
Spirited's Avatar
 
elite*gold: 12
Join Date: Jul 2011
Posts: 8,205
Received Thanks: 4,107
Also, why are you still reading the file like that? Just read and write to it asynchronously. But wait - why the hell is it a text file? Why aren't you doing this in SQL? Why flat-file?
Spirited is offline  
Old 09/12/2014, 03:49   #14
 
{ Angelius }'s Avatar
 
elite*gold: 0
Join Date: Aug 2010
Posts: 991
Received Thanks: 1,107
Quote:
Originally Posted by iliveoncaffiene View Post
Code:
using (var SW = (mod == Mode.Open ? new StreamWriter(location, false, Encoding.Default) : 
new StreamWriter(File.Create(location))))
If you must...
Code:
using (var SW = new StreamWriter(new FileStream(Path, FileMode.OpenOrCreate)))
Quote:
Originally Posted by Xio. View Post
Eliminates readability too imo.
Come again!!! Eliminates what?
{ Angelius } is offline  
Old 09/12/2014, 03:52   #15
 
elite*gold: 67
Join Date: Aug 2014
Posts: 1,321
Received Thanks: 927
Readability. English ************, do you speak it? (Was going to put the meme but too few posts, imagine Samuel L Jackson)
Xio. is offline  
Reply


Similar Threads Similar Threads
Error trying access httpd.conf file.
07/30/2013 - Technical Support - 8 Replies
http://i.epvpimg.com/fnNDd.png Hilft mir mal jemand ? Lg.
'Download des Process File fehlgeschlagen'
06/21/2013 - Elsword - 11 Replies
Hallo liebe Community, ich habe folgendes Problem,von dem ihr vielleicht schon gehört habt,da es ziemlich verbreitet ist:Ich öffne Elsword wie gewohnt und warte bis es zu Ende aktualisiert/geprüft hat.Aber seit gestern ,als ich zum ersten Mal (an diesem Tag) wieder den PC anmachte um Elsword zu spielen,funktionierte Els mehr. Nach zirka 3Minuten Wartezeit erscheint jedes Mal folgendes Fenster: http://im.bilderkiste.org/4137184097505/elsword_f ehler.png Ich habe heute zirka 6 Stunden...
The vb.net command to delete a file in order Process with vb.net.
08/11/2012 - .NET Languages - 0 Replies
http://pic.free.in.th/id/8b8cc02259e8ebb9c036e7a7e 8514a71It is a command to delete a file in a vb.net Process Hacke, please help me thank you very much as in me is very difficult. Help it by arrow I in order to be removed.
injecting a file to process?
01/07/2012 - AutoIt - 1 Replies
Need help on injecting a file (dds image file) into a process at a specific address.
File Access Denied!
06/02/2011 - Dekaron Private Server - 0 Replies
Hey all, I went to put in a new update earlier, but when I pressed "Load files" on the updater thingy, it said "File Access Denied". I pressed "Pack Files" and it says "List index is out of bounds (1). What did I do o.O!?



All times are GMT +1. The time now is 03:06.


Powered by vBulletin®
Copyright ©2000 - 2024, 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 ©2024 elitepvpers All Rights Reserved.