Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > C# and C > C# 2005 > C# 2005
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
C# 2005 For discussion of Visual C# 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# 2005 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 13th, 2007, 12:40 PM
Registered User
 
Join Date: Apr 2007
Location: Warwick, Warwickshire, United Kingdom.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default C# app doesn't release files after creation

Hi, I am writing a small app in C# and part of it is testing if it has permissions to write to a location. The code for the method is:
Code:
private void test_permissions()
{
   FileInfo config2 = new FileInfo(local.Text + "\\cstest.txt");
   config2.Create();
   config2.Delete();
}
When I call the method, giving it a path that is accessible, it creates the file, but then throws an exception, the text it "The process cannot access the file 'C:\Users\Toby\Documents\cstest.txt' because it is being used by another process." If I try to manually delete the file while the program is still running I get a similar message from Windows (Vista Ultimate 32-bit if it helps), but when I close the program I can delete it. I can't work out why it locks the file.

Thanks for your help,

gandaliter
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Compressing and expanding files within an app alantodd Pro VB Databases 1 May 8th, 2006 04:12 PM
Permissions for Web app. files on Web server Jan_Ma Classic ASP Basics 0 June 28th, 2003 02:06 PM
Permissions for Web app. files on server Jan_Ma All Other Wrox Books 0 June 28th, 2003 02:02 PM



All times are GMT -4. The time now is 11:23 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.