Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 2005 > C# 2005
|
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 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 April 13th, 2007, 12:40 PM
Registered User
 
Join Date: Apr 2007
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





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





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