.NET Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgramming.NET Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old May 12th, 2003, 05:02 PM
jl39775 jl39775 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: May 2003
Posts: 4 jl39775 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
How do I close a text file?

I have a web form that allows users to upload text files to the web server then my code opens the text file and stores the data to a database. That all works. However, if the text file is not in the correct format, I allow the user to fix the text file and try to upload again. My problem is I don't know how to close the text file. When the user try to upload again I receive the following error. I believe it's because the file is still open and locked. <br><br>Access to the path "c:inetpubwwwrootWylePricingSystemWeeklyLaborArchiv eBAWeeklyHours050403.txt" is denied. <br><br>I tried to fix my problem by catching the error, then trying to close the objStreamReader hoping it would close the file so I can delete it. <br><br>Does anyone know how I can solve my problem? Look below at what I trying to do. <br><br>Dim myFileName as string <br>Dim objStreamReader As StreamReader <br><br>myFileName=session("filename") <br>try <br><br>objStreamReader = File.OpenText("c:inetpubwwwrootWylePricingSystemWeeklyLaborArchiv e"" + myFileName) <br>. <br>. <br>. <br>catch err As Exception <br> Response.Write(err.Message.ToString) <br> objStreamReader.DiscardBufferedData() <br> objStreamReader.Close() <br><br><br> File.Delete("c:inetpubwwwrootWylePricingSystemWeeklyLaborArchiv e"" + myFileName) <br> End Try <br><br>Thanks, <br><br>James

Reply With Quote
  #2  
Old May 13th, 2003, 10:17 PM
dcarva's Avatar
dcarva dcarva is offline
Contributing User
ASP Free Novice (500 - 999 posts)
 
Join Date: Jan 2003
Location: USA
Posts: 633 dcarva User rank is Lance Corporal (50 - 100 Reputation Level)dcarva User rank is Lance Corporal (50 - 100 Reputation Level)dcarva User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 9 h 18 m 20 sec
Reputation Power: 6
Check out this article. You'll have to read all entries...<br><br><a href="http://www.experts-exchange.com/Programming/Programming_Languages/Dot_Net/Q_20431740.html" target="_blank">www.experts-exchange.com/Programming/Programming_Languages/Dot_Net/Q_20431740.html</a><br>Danny<br><br> <img border="0" src="/forum/emoticons/shocked.gif" height="15" width="15" alt="shocked" />

Reply With Quote
Reply

Viewing: ASP Free ForumsProgramming.NET Development > How do I close a text file?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT