Wrox Programmer Forums
|
Visual Basic 2005 Basics If you are new to Visual Basic programming with version 2005, this is the place to start your questions. For questions about the book: Beginning Visual Basic 2005 by Thearon Willis and Bryan Newsome, ISBN: 0-7645-7401-9 please, use this forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual Basic 2005 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 31st, 2011, 01:55 PM
Registered User
 
Join Date: May 2011
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default File release

I am trying to get info to go into a file. The problem I am having is once I create the file and then try to write to it it says the file is being used by another process. Does anyone know how to release the file after it has been created using the System.IO.file

Thank you
Jeremy
 
Old May 31st, 2011, 08:54 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

Hi there..

flush and dispose??

But you have to wait a little until the OS realize that the file is alone...

Anyway, why using two diferent process?? you can create the file opening a stream for writting....
__________________
HTH

Gonzalo


================================================== =========
Read this if you want to know how to get a correct reply for your question.
(Took that from Doug signature and he Took that from Peter profile)
================================================== =========
My programs achieved a new certification :
WORKS ON MY MACHINE
================================================== =========
I know that CVS was evil, and now i got the
proof.
================================================== =========
 
Old June 4th, 2011, 09:15 AM
Friend of Wrox
 
Join Date: Jun 2005
Posts: 244
Thanks: 3
Thanked 4 Times in 4 Posts
Default

when you create a file, you can create it and append to it in 1 instance, you dont have to create a file, close it, then re open it for editing.

So you would do something like

Code:
Dim fStream As New FileStream("mytxt.txt", FileMode.OpenOrCreate)
        Dim tStream As New StreamWriter(fStream)

        ' Do what ever writing you need to, or what ever reading you need

        tStream.Flush()
        fStream.Flush()
        tStream.Dispose()
        fStream.Dispose()
__________________
Apocolypse2005, I'm a programmer - of sorts.





Similar Threads
Thread Thread Starter Forum Replies Last Post
File release Jeremy.Carter Javascript How-To 2 May 27th, 2011 04:54 AM
Release Date tlpearceii BOOK: Silverlight 4 Problem - Design - Solution 0 April 22nd, 2010 01:11 PM
debug vs. release xagutxu Visual C++ 0 September 16th, 2009 07:46 AM
Need to release file after File.Create... VBtyler Visual Basic 2008 Essentials 2 May 19th, 2009 07:12 AM
Release problem jeusdi .NET Framework 1.x 0 February 27th, 2007 11:19 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.