473,395 Members | 1,823 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Having a hard time trying to open a text file

Hello.

I developed a web consuming windows application/form program with VS.NET
2003, VB, .Net Framework 1.1.4322, ASP.NET 1.1.4322, IIS 5.1.

Using this code to open a simple text file. If i get an error in my program
after the file has been opened once, it gives me a message saying
"System.IO.IOException: File already open."

FileOpen(1, "C:\xmltrips.txt", OpenMode.Output, OpenAccess.Write)

WriteLine(1, txtFilStr)

When i try to delete it, it says "It is being used by another person or
program".

If it's being opened output, then why won't it open again and again ?

I have a FileClose(1) in the catch statement.

Any help would be gratefully appreciated.

Thanks,
Tony
Sep 13 '06 #1
13 1501
"Tony Girgenti" <tony(nospam)@lakesideos.comwrote in message
news:uz**************@TK2MSFTNGP05.phx.gbl...
Hello.

I developed a web consuming windows application/form program with VS.NET
2003, VB, .Net Framework 1.1.4322, ASP.NET 1.1.4322, IIS 5.1.

Using this code to open a simple text file. If i get an error in my
program after the file has been opened once, it gives me a message saying
"System.IO.IOException: File already open."

FileOpen(1, "C:\xmltrips.txt", OpenMode.Output, OpenAccess.Write)

WriteLine(1, txtFilStr)

When i try to delete it, it says "It is being used by another person or
program".

If it's being opened output, then why won't it open again and again ?

I have a FileClose(1) in the catch statement.

Any help would be gratefully appreciated.
What are FileOpen and FileClose? I don't recognize them

John
Sep 13 '06 #2
Hello John.

I copied everything from here:
http://msdn.microsoft.com/library/de.../vastmOpen.asp

Thanks,
Tony

"John Saunders" <john.saunders at trizetto.comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
"Tony Girgenti" <tony(nospam)@lakesideos.comwrote in message
news:uz**************@TK2MSFTNGP05.phx.gbl...
>Hello.

I developed a web consuming windows application/form program with VS.NET
2003, VB, .Net Framework 1.1.4322, ASP.NET 1.1.4322, IIS 5.1.

Using this code to open a simple text file. If i get an error in my
program after the file has been opened once, it gives me a message saying
"System.IO.IOException: File already open."

FileOpen(1, "C:\xmltrips.txt", OpenMode.Output, OpenAccess.Write)

WriteLine(1, txtFilStr)

When i try to delete it, it says "It is being used by another person or
program".

If it's being opened output, then why won't it open again and again ?

I have a FileClose(1) in the catch statement.

Any help would be gratefully appreciated.

What are FileOpen and FileClose? I don't recognize them

John


Sep 13 '06 #3
"Tony Girgenti" <tony(nospam)@lakesideos.comwrote in message
news:Oo**************@TK2MSFTNGP05.phx.gbl...
Hello John.

I copied everything from here:
http://msdn.microsoft.com/library/de.../vastmOpen.asp
I see. I've never used these. Good luck.

John
Sep 13 '06 #4
Using this code to open a simple text file. If i get an error in my
program after the file has been opened once, it gives me a message saying
"System.IO.IOException: File already open."
Thru a web-service?

Well, probably, multiple requests on the Web-Service is causing the error.

I would suggest using database rather than files to avoid concurrency
issues.

--
Happy Hacking,
Gaurav Vaish | http://www.mastergaurav.com
http://www.edujinionline.com
http://articles.edujinionline.com/webservices
-------------------
Sep 14 '06 #5
Hell Gaurav.

If i use a database, how would i get the data from the database to the
mainframe ?

Thanks,
Tony

"Gaurav Vaish (www.EduJiniOnline.com)"
<ga*****************@nospam.gmail.comwrote in message
news:e7**************@TK2MSFTNGP04.phx.gbl...
>Using this code to open a simple text file. If i get an error in my
program after the file has been opened once, it gives me a message saying
"System.IO.IOException: File already open."

Thru a web-service?

Well, probably, multiple requests on the Web-Service is causing the error.

I would suggest using database rather than files to avoid concurrency
issues.

--
Happy Hacking,
Gaurav Vaish | http://www.mastergaurav.com
http://www.edujinionline.com
http://articles.edujinionline.com/webservices
-------------------


Sep 14 '06 #6
If i use a database, how would i get the data from the database to the
mainframe ?
Same way as you would do from the file.
Or do you have the file on the MainFrame?

If so, you may install MSDE on the machine with .Net.
Make a simple table with only one field -- say, contents of type, may
be, blob.
Push all the contents in field as what you would push in the file.

This is the simplest way that you may leave the file and use database.
If the content in file is structured, you may created more fields in
database.
--
Happy Hacking,
Gaurav Vaish | http://www.mastergaurav.com
http://www.edujinionline.com
http://articles.edujinionline.com/webservices
-------------------
Sep 15 '06 #7
I guess my point is, if i can't use a file in my web application to capture
the data during program operation, then how will i create and use a file in
my web application taking the data from the database. In other words,
what's the difference whether i create the file during program operation or
whether it creates the file afterwards reading from the database ?

Thanks,
Tony

"Gaurav Vaish (www.EduJiniOnline.com)"
<ga*****************@nospam.gmail.comwrote in message
news:eh**************@TK2MSFTNGP04.phx.gbl...
>If i use a database, how would i get the data from the database to the
mainframe ?

Same way as you would do from the file.
Or do you have the file on the MainFrame?

If so, you may install MSDE on the machine with .Net.
Make a simple table with only one field -- say, contents of type, may
be, blob.
Push all the contents in field as what you would push in the file.

This is the simplest way that you may leave the file and use database.
If the content in file is structured, you may created more fields in
database.
--
Happy Hacking,
Gaurav Vaish | http://www.mastergaurav.com
http://www.edujinionline.com
http://articles.edujinionline.com/webservices
-------------------


Sep 15 '06 #8
You may want to try including OpenShare.Shared when you make your
FileOpen() call. The system may grant you shared access to the file,
depending on what the other process is that has previously accessed it.

Tony Girgenti (nospam) wrote:
Hello.

I developed a web consuming windows application/form program with VS.NET
2003, VB, .Net Framework 1.1.4322, ASP.NET 1.1.4322, IIS 5.1.

Using this code to open a simple text file. If i get an error in my program
after the file has been opened once, it gives me a message saying
"System.IO.IOException: File already open."

FileOpen(1, "C:\xmltrips.txt", OpenMode.Output, OpenAccess.Write)

WriteLine(1, txtFilStr)

When i try to delete it, it says "It is being used by another person or
program".

If it's being opened output, then why won't it open again and again ?

I have a FileClose(1) in the catch statement.

Any help would be gratefully appreciated.

Thanks,
Tony
Sep 16 '06 #9
>I guess my point is, if i can't use a file in my web application to capture
>the data during program operation, then how will i create and use a file in
my web application taking the data from the database. In other words,
what's the difference whether i create the file during program operation or
whether it creates the file afterwards reading from the database ?
Oh!
I thought the otherwise.... that you are using file to read the data from
:-)

In that case, you may create a temporary file with a random name.
System.IO.Path.GetTempFileName method

Push all open/write in a try block.
Have the 'Close' in 'finally' block.

HTH

--
Happy Hacking,
Gaurav Vaish | http://www.mastergaurav.com
http://www.edujinionline.com
http://articles.edujinionline.com/webservices
-------------------
Sep 17 '06 #10
Gaurav.

Now that i have spent two days trying to figure out how to use a
dataset/database to put my data into, i'm not sure i want to go back to
using a flat text file.

Does thae fact that GetTempFileName has the word "Temp" in it tell me
anything. Should i wonder if the file will remain after the program
terminates ?

Thanks,
Tony

"Gaurav Vaish (www.EduJiniOnline.com)"
<ga*****************@nospam.gmail.comwrote in message
news:eu**************@TK2MSFTNGP04.phx.gbl...
I guess my point is, if i can't use a file in my web application to
capture the data during program operation, then how will i create and use
a file in my web application taking the data from the database. In other
words, what's the difference whether i create the file during program
operation or whether it creates the file afterwards reading from the
database ?

Oh!
I thought the otherwise.... that you are using file to read the data from
:-)

In that case, you may create a temporary file with a random name.
System.IO.Path.GetTempFileName method

Push all open/write in a try block.
Have the 'Close' in 'finally' block.

HTH

--
Happy Hacking,
Gaurav Vaish | http://www.mastergaurav.com
http://www.edujinionline.com
http://articles.edujinionline.com/webservices
-------------------


Sep 17 '06 #11
Does thae fact that GetTempFileName has the word "Temp" in it tell me
anything. Should i wonder if the file will remain after the program
terminates ?
Yes.
The folder in which it is created is always Path.GetTempPath
The name is randomly chosen so that it is unique.
The extension is always .tmp
The prefix is always tmp
The file is not temporary in the sense that it is not automatically deleted.
The method is a wrapper around the native method GetTempFileName.
The details of the native method is available at:
http://msdn.microsoft.com/library/de...mpfilename.asp

When the system shuts down, temporary files whose names have been created by
this function are not automatically deleted.

--
Happy Hacking,
Gaurav Vaish | http://www.mastergaurav.com
http://www.edujinionline.com
http://articles.edujinionline.com/webservices
-------------------
Sep 17 '06 #12
Considering this, since i want the file to be available after the program
terminates, i don't think i should use this method to store my data. Even
though the file is not automatically deleted.

Do you agree ?

Thanks,
Tony

"Gaurav Vaish (www.EduJiniOnline.com)"
<ga*****************@nospam.gmail.comwrote in message
news:uI**************@TK2MSFTNGP06.phx.gbl...
>Does thae fact that GetTempFileName has the word "Temp" in it tell me
anything. Should i wonder if the file will remain after the program
terminates ?

Yes.
The folder in which it is created is always Path.GetTempPath
The name is randomly chosen so that it is unique.
The extension is always .tmp
The prefix is always tmp
The file is not temporary in the sense that it is not automatically
deleted.
The method is a wrapper around the native method GetTempFileName.
The details of the native method is available at:
http://msdn.microsoft.com/library/de...mpfilename.asp

When the system shuts down, temporary files whose names have been created
by this function are not automatically deleted.


--
Happy Hacking,
Gaurav Vaish | http://www.mastergaurav.com
http://www.edujinionline.com
http://articles.edujinionline.com/webservices
-------------------


Sep 18 '06 #13
Considering this, since i want the file to be available after the program
terminates, i don't think i should use this method to store my data. Even
though the file is not automatically deleted.

Do you agree ?
Strictly speaking, all that is required is a valid, random, new name.
You have the following options:

1. Generate yourself
2. Ask somebody to generate
2a. Use GetTempFileName
2b. Directly invoke GetTempFileName since it can work with
non-GetTempPath folders as well.

--
Happy Hacking,
Gaurav Vaish | http://www.mastergaurav.com
http://www.edujinionline.com
http://articles.edujinionline.com/webservices
-------------------
Sep 19 '06 #14

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: longtim | last post by:
I have been having endless difficulty creating reports/queries that set any relevent parameters from controls in forms. I am creating an application under access 2003 but will target access...
3
by: sparks | last post by:
I am building a web ap and have a webform1 an agreement.cs and a files.cs going to an access database I am not having problems reading or writing to the database but I have hit a snag on how to keep...
1
by: Ruy Castelli | last post by:
I created a ASP.NET page using C# and I'm using two components to access a MS-Access database, which are: - oleDbConnection - oleDataAdapter The MS-Access database is in the correct directory...
1
by: KShapiro | last post by:
Hi All, I am trying to assist my wife, by making a simple menu system for the website. The web page is a .php4 file and does an include of the navigation file. Before it includes that file at...
13
by: Tony Girgenti | last post by:
Hello. I developed a web consuming windows application/form program with VS.NET 2003, VB, .Net Framework 1.1.4322, ASP.NET 1.1.4322, IIS 5.1. Using this code to open a simple text file. If i...
0
by: Tony Girgenti | last post by:
Hello. I developed and tested a web application using VS.NET 2003, VB, .NET Framework 1.1.4322, ASP.NET 1.1.4322 and IIS5.1. It uses a web form. I'm having the darndest time trying to make...
13
by: ragtag99 | last post by:
I posted this on comp.lang.asm.x86, alt.os.development, comp.arch, comp.lang.c++ Im working with windows xp professional, NTFS and programming with MASM, c++ (free compiler) or visual basic 6.0...
0
grassh0pp3r
by: grassh0pp3r | last post by:
Hello, I'm trying to make a very simple comments page on my site using PHP and am having problems somewhere. I am very new to PHP. I was able to create one that works with comments appended, but...
8
by: sabby | last post by:
I want to use the getline() so that i can enter a entire name in on line. (with spaces) The prob is that i am initializing the variable as "N/A" and saving it to a text file. it is declared as a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.