with the next code you can see if you can exclusively open the the file:
FileInfo fi = new FileInfo(FolderAndFileName);
FileStream stream = null;
using (stream = File.Open(FolderAndFileName, FileMode.Open, FileAccess.Write, FileShare.None))
If the stream.CanWrite you can access the file.
Other probles is that you check in the code if the file exists. If it does not you will not write any file!
Second if the file is found delete it first. You can always write a new file than with the same name.