Results 1 to 6 of 6

Thread: forcibly close a file [resolved]

  1. #1

    Thread Starter
    Hyperactive Member stingrae's Avatar
    Join Date
    Apr 2002
    Location
    Sydney
    Posts
    401

    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

  2. #2
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    Quit using the FileOpen command and use the System.IO namespace. Use streams.

  3. #3
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    Quit using the FileOpen command and use the System.IO namespace. Use streams.

  4. #4

    Thread Starter
    Hyperactive Member stingrae's Avatar
    Join Date
    Apr 2002
    Location
    Sydney
    Posts
    401
    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

  5. #5
    Frenzied Member dynamic_sysop's Avatar
    Join Date
    Jun 2003
    Location
    Ashby, Leicestershire.
    Posts
    1,142
    to open a file / read it ....
    VB Code:
    1. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    2.         Dim path As String = "C:\some path.txt"
    3.         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.
    4.             Dim sReader As New IO.StreamReader(New IO.FileStream(path, IO.FileMode.Open))
    5.             While Not sReader.Peek = -1
    6.                 TextBox1.AppendText(sReader.ReadLine) '/// assuming you want it in a textbox in this case. ( reading each line at a time )
    7.             End While
    8.         Else
    9.             '/// the file doesnt exist yet!
    10.         End If
    11.     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]

  6. #6

    Thread Starter
    Hyperactive Member stingrae's Avatar
    Join Date
    Apr 2002
    Location
    Sydney
    Posts
    401
    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
  •  



Click Here to Expand Forum to Full Width