How careless cud I be....i did not notice File.Create returns a Filestream and expected it to close it for me... Thanks a lot....
Regards, Sarvajith -----Original Message----- From: Unmoderated discussion of advanced .NET topics. [mailto:[EMAIL PROTECTED] On Behalf Of Eduard Lascu Sent: Tuesday, 05 July 2005 6:17 PM To: [email protected] Subject: Re: [ADVANCED-DOTNET] System.IO.IOException was unhandled Check the example in MSDN - FileStream fs = File.Create(@"C:\test.test"); // you need to close the file stream before you delete the file fs.Close(); // it is safe to delete the file now File.Delete(@"C:\test.test"); HTH, Eddie -----Original Message----- From: Unmoderated discussion of advanced .NET topics. [mailto:[EMAIL PROTECTED] Behalf Of Chakravarty, Sarvajith Sent: Tuesday, July 05, 2005 8:35 AM To: [email protected] Subject: [ADVANCED-DOTNET] System.IO.IOException was unhandled I am facing a strange problem. I have just 2 lines of code - File.Create (@"C:\test.test"); File.Delete (@"C:\test.test"); (I am using File in System.IO namespace) When I execute I get the following error and am not able to tackle this problem. Any help will be appreciated- System.IO.IOException was unhandled Message="The process cannot access the file 'C:\\test.test1' because it is being used by another process." Source="mscorlib" StackTrace: at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.FileInfo.Delete() at ConsoleApplication4.Program.Main(String[] args) in C:\Documents and Settings\i032271\My Documents\Visual Studio Projects\ConsoleApplication4\Program.cs:line 31 at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args) at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart() Regards, Sarvajith =================================== This list is hosted by DevelopMentor. http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com =================================== This list is hosted by DevelopMentor(r) http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com =================================== This list is hosted by DevelopMentorĀ® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com
