|
-
Dec 17th, 2003, 12:34 AM
#1
Thread Starter
Hyperactive Member
forcibly close a file [resolved]
I'm trying to open a file for reading, as in the following code:
Code:
FileOpen(1, strTemp, OpenMode.Binary)
and everytime i keep getting a message saying the File Is Already Open.
i have used this file previously in the application (in another function) and have closed it.
does anybody know if there's a way to forcibly close all applications that are using a file?
thanks
R
Last edited by stingrae; Dec 17th, 2003 at 07:11 PM.
"The passion lives to keep your faith, though all are different, all are great" ... Michael Hutchence 1960-1997.
Windows & Web Developer
Specialising in Visual Basic .Net & Client Server Programming & Client/Customer Relations Databases
Sutherland Shire, Sydney Australia
www.stingrae.com.au
Developer of Arnold - Gym & Martial Arts Database Management System
www.gymdatabase.com.au
-
Dec 17th, 2003, 01:38 AM
#2
PowerPoster
Quit using the FileOpen command and use the System.IO namespace. Use streams.
-
Dec 17th, 2003, 01:38 AM
#3
PowerPoster
Quit using the FileOpen command and use the System.IO namespace. Use streams.
-
Dec 17th, 2003, 05:29 PM
#4
Thread Starter
Hyperactive Member
hi, thanks for that.
do you have a quick example? i'm not familiar with streams.
cheers.
"The passion lives to keep your faith, though all are different, all are great" ... Michael Hutchence 1960-1997.
Windows & Web Developer
Specialising in Visual Basic .Net & Client Server Programming & Client/Customer Relations Databases
Sutherland Shire, Sydney Australia
www.stingrae.com.au
Developer of Arnold - Gym & Martial Arts Database Management System
www.gymdatabase.com.au
-
Dec 17th, 2003, 05:52 PM
#5
to open a file / read it ....
VB Code:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim path As String = "C:\some path.txt"
If IO.File.Exists(path) Then '/// check it exists , although you can use " IO.FileMode.OpenOrCreate " below instead of this , depending if you want the file to be created if it don't exist.
Dim sReader As New IO.StreamReader(New IO.FileStream(path, IO.FileMode.Open))
While Not sReader.Peek = -1
TextBox1.AppendText(sReader.ReadLine) '/// assuming you want it in a textbox in this case. ( reading each line at a time )
End While
Else
'/// the file doesnt exist yet!
End If
End Sub
~
if a post is resolved, please mark it as [Resolved]
protected string get_Signature(){return Censored;}
[vbcode][php] please use code tags when posting any code [/php][/vbcode]
-
Dec 17th, 2003, 07:10 PM
#6
Thread Starter
Hyperactive Member
thankyou sirs!
"The passion lives to keep your faith, though all are different, all are great" ... Michael Hutchence 1960-1997.
Windows & Web Developer
Specialising in Visual Basic .Net & Client Server Programming & Client/Customer Relations Databases
Sutherland Shire, Sydney Australia
www.stingrae.com.au
Developer of Arnold - Gym & Martial Arts Database Management System
www.gymdatabase.com.au
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|