The process cannot access the file because it is being used by another process
This is common problem, when we create file using File.Create() method.
When we use File.Create() method to create file then the object of FileStream class is created and no other process can use or access the created file until the file is closed.
This problem can be easily resolved by modifying your code like this-
Means use Close () with File.Create () method. It will create the file and after that it will close the related file.