Watch Pre-recorded Live Shows Here
Why Join
Become a member
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
C# Corner Home
Technologies
Monthly Leaders
ASK A QUESTION
Forum guidelines
John
1.3k
928
107.3k
FIle delete exception
Feb 9 2018 4:05 AM
string FilePath = @"D:\WebSite1\Folder\open.txt";
try
{
System.IO.File.CreateText(FilePath);
bool fileExist = false;
while (!fileExist)
{
FileInfo sFile = new FileInfo(@"D:\WebSite1\Folder\close.txt");
fileExist = sFile.Exists;
}
System.IO.File.Delete(@"D:\WebSite1\Folder\open.txt");
System.IO.File.Delete(@"D:\WebSite1\Folder\close.txt");
}
catch (Exception ex)
{
}
above code throws ex of The process cannot access the file 'D:\\WebSite1\\Folder\\open.txt' because it is being used by another process.
Reply
Answers (
1
)
Microsoft Certification
Message Preview with Number