BleepingComputer.com: Problems with access violdation

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Problems with access violdation VB.NET (2008)

#1 User is offline   PlyPencil 

  • Member
  • PipPip
  • Find Topics
  • Group: Members
  • Posts: 51
  • Joined: 26-September 08

  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.

#2 User is online   groovicus 

  • Hail Groovicus!
  • PipPipPipPipPipPip
  • Find Topics
  • Group: Moderator
  • Posts: 9,605
  • Joined: 05-June 04
  • Gender:Male
  • Location:Centerville, SD

Posted 29 October 2008 - 01:49 PM

Are you closing the file stream after you read from or write to the file?
"Take the risk of thinking for yourself, much more happiness, truth, beauty, and wisdom will come to you that way" - Christopher Hitchens

#3 User is offline   PlyPencil 

  • Member
  • PipPip
  • Find Topics
  • Group: Members
  • Posts: 51
  • Joined: 26-September 08

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 User is online   groovicus 

  • Hail Groovicus!
  • PipPipPipPipPipPip
  • Find Topics
  • Group: Moderator
  • Posts: 9,605
  • Joined: 05-June 04
  • Gender:Male
  • Location:Centerville, SD

Posted 29 October 2008 - 03:58 PM

Well that one line of code really isn't going to help us solve your problem. :thumbsup:
"Take the risk of thinking for yourself, much more happiness, truth, beauty, and wisdom will come to you that way" - Christopher Hitchens

#5 User is offline   PlyPencil 

  • Member
  • PipPip
  • Find Topics
  • Group: Members
  • Posts: 51
  • Joined: 26-September 08

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

This post has been edited by PlyPencil: 29 October 2008 - 04:11 PM


Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users