Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

Problems with access violdation


  • Please log in to reply
4 replies to this topic

#1 PlyPencil

PlyPencil

  • Members
  • 51 posts
  • OFFLINE
  •  
  • Local time:09:44 PM

Posted 29 October 2008 - 01:13 PM

Hello, I have the following code

system.io.file.create("C:\Program Files\ColemanSystems\Intercapedo\Data\Buildings\index.csf")

Then I try to write data via a stream writer and it throws an error saying the file is being used by another process.....my own one lol. How do I stop this problem? because it is not practicle to restart the game every time.

Thanks for any help
Ply.

BC AdBot (Login to Remove)

 


#2 groovicus

groovicus

  • Security Colleague
  • 9,963 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Centerville, SD
  • Local time:02:44 PM

Posted 29 October 2008 - 01:49 PM

Are you closing the file stream after you read from or write to the file?

#3 PlyPencil

PlyPencil
  • Topic Starter

  • Members
  • 51 posts
  • OFFLINE
  •  
  • Local time:09:44 PM

Posted 29 October 2008 - 02:10 PM

When I read data yes I do, but I do not know how to close the file when creating it. No data is being written to it until the next stage, which throws the error.

#4 groovicus

groovicus

  • Security Colleague
  • 9,963 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Centerville, SD
  • Local time:02:44 PM

Posted 29 October 2008 - 03:58 PM

Well that one line of code really isn't going to help us solve your problem. :thumbsup:

#5 PlyPencil

PlyPencil
  • Topic Starter

  • Members
  • 51 posts
  • OFFLINE
  •  
  • Local time:09:44 PM

Posted 29 October 2008 - 04:09 PM

The code has not been optimized nor managed due to it being completely rewritten about 7 times in the past 4 days lol

Sub call_load()
On Error Resume Next
Load.PictureBox1.Update()
Load.PictureBox1.Refresh()

'reset defaults
Load.Text = "Processing"
Load.Label1.Text = ""
Load.ProgressBar1.Value = 0
Load.ProgressBar1.Maximum = 100
Load.Update()

'___________________________________________________________

If My.Computer.FileSystem.FileExists("C:\Program Files\ColemanSystems\Intercapedo\Data\" + sectorname + "_terrain.csf") = False Then
MsgBox("Error: File Not Found")
system.io.file.create("C:\Program Files\ColemanSystems\Intercapedo\Data\" + sectorname + "_terrain.csf")
End If
Dim tr4 As New IO.StreamReader("C:\Program Files\ColemanSystems\Intercapedo\Data\" + sectorname + "_terrain.csf")

Load.Label1.Text = "Loading Terrain Data"
Load.ProgressBar1.Value = 0
Load.Update()

coX = 1
coY = 1

TerrainDataMaximum(0) = 22500
TerrainDataMinimum(0) = 1
'creates an array of objects numbered lowerbounds - l (L)
TerrainData = Array.CreateInstance(GetType(System.String), TerrainDataMaximum, TerrainDataMinimum)
2:

LineNO += 1
LineNO2 += 1
Load.Label1.Text = "Loading Main Data - " + Load.ProgressBar1.Value.ToString + "%"
TerrainData.SetValue(tr4.ReadLine, LineNO)
If LineNO2 = 22500 Then
GoTo 3
End If
GoTo 2
3:
LineNO = 0
LineNO2 = 0
Load.Label1.Text = ("Terrain Data loaded")

Load.ProgressBar1.Value = 25
Load.Update()
'__________________________________________________________________



If My.Computer.FileSystem.FileExists("C:\Program Files\ColemanSystems\Intercapedo\Data\" + sectorname + "_parent.csf") = False Then
MsgBox("Error: File Not Found")
system.io.file.create("C:\Program Files\ColemanSystems\Intercapedo\Data\" + sectorname + "_parent.csf")
End If

Dim tr5 As New IO.StreamReader("C:\Program Files\ColemanSystems\Intercapedo\Data\" + sectorname + "_parent.csf")

Load.Label1.Text = "Loading Parent Data"
Load.Label1.Update()
Load.Update()

coX = 1
coY = 1

ParentDataMaximum(0) = 22500
ParentDataMinimum(0) = 1
'creates an array of objects numbered lowerbounds - l (L)
ParentData = Array.CreateInstance(GetType(System.String), ParentDataMaximum, ParentDataMinimum)
4:

LineNO += 1
LineNO2 += 1
Load.Label1.Text = "Loading Parent Data - " + Load.ProgressBar1.Value.ToString + "%"
ParentData.SetValue(tr5.ReadLine, LineNO)
If LineNO2 = 22500 Then
GoTo 5
End If
GoTo 4
5:
LineNO = 0
LineNO2 = 0
Load.Label1.Text = ("Parent Data loaded")

Load.ProgressBar1.Value = 50
Load.Update()

'__________________________________________________________________




If My.Computer.FileSystem.FileExists("C:\Program Files\ColemanSystems\Intercapedo\Data\" + sectorname + "_child.csf") = False Then
MsgBox("Error: File Not Found")
system.io.file.create("C:\Program Files\ColemanSystems\Intercapedo\Data\" + sectorname + "_child.csf")
End If
Dim tr6 As New IO.StreamReader("C:\Program Files\ColemanSystems\Intercapedo\Data\" + sectorname + "_child.csf")

Load.Label1.Text = "Loading Child Data"
Load.Label1.Update()
Load.Update()

coX = 1
coY = 1

ChildDataMaximum(0) = 22500
ChildDataMinimum(0) = 1
'creates an array of objects numbered lowerbounds - l (L)
ChildData = Array.CreateInstance(GetType(System.String), ChildDataMaximum, ChildDataMinimum)
7:

LineNO += 1
LineNO2 += 1
Load.Label1.Text = "Loading Child Data - " + Load.ProgressBar1.Value.ToString + "%"
ChildData.SetValue(tr6.ReadLine, LineNO)
If LineNO2 = 22500 Then
GoTo 8
End If
GoTo 7
8:
LineNO = 0
LineNO2 = 0
Load.Label1.Text = ("Child Data loaded")

Load.ProgressBar1.Value = 75
Load.Update()


'__________________________________________________________________




If My.Computer.FileSystem.FileExists("C:\Program Files\ColemanSystems\Intercapedo\Data\" + sectorname + "_building.csf") = False Then
MsgBox("Error: File Not Found")
System.IO.File.Create("C:\Program Files\ColemanSystems\Intercapedo\Data\" + sectorname + "_building.csf")
End If
Dim tr7 As New IO.StreamReader("C:\Program Files\ColemanSystems\Intercapedo\Data\" + sectorname + "_building.csf")

Load.Label1.Text = "Loading Building Data"
Load.Label1.Update()
Load.Update()

coX = 1
coY = 1

BuildingDataMaximum(0) = 22500
BuildingDataMinimum(0) = 1
'creates an array of objects numbered lowerbounds - l (L)
BuildingData = Array.CreateInstance(GetType(System.String), BuildingDataMaximum, BuildingDataMinimum)
9:

LineNO += 1
LineNO2 += 1
Load.Label1.Text = "Loading Building Data - " + Load.ProgressBar1.Value.ToString + "%"
BuildingData.SetValue(tr7.ReadLine, LineNO)
If LineNO2 = 22500 Then
GoTo 10
End If
GoTo 9
10:
LineNO = 0
LineNO2 = 0
Load.Label1.Text = ("Building Data loaded")

Load.ProgressBar1.Value = 100
Load.Update()


'_____________________________________
buildingID = 0
coX = 0
coY = 1
11:

LineNO += 1
coX += 1
If BuildingData.GetValue((150 * coY) + coX) > buildingID Then
BuildingData = BuildingData.GetValue((150 * coY) + coX)
End If

If coX = 150 Then
coY += 1
coX = 0
End If
If coY = 150 Then
GoTo 12
End If
GoTo 11
12:
LineNO = 0



Universe.panel3.ImageLocation = ("C:\Program Files\ColemanSystems\Intercapedo\Data\" + sectorname + "_minimapx1.cif")




tr4.Close()
Universe.Show()
Load.Hide()
Universe.Panel1.Refresh()
666:





coX = 1
coY = 1


End Sub

Edited by PlyPencil, 29 October 2008 - 04:11 PM.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users