16. May 2007 08:25
The SPFileCollection has no 'Exists' or 'Contains' method you can use to verify the existence of a file. It seems the appropriate method is to first Get the file, which will not fail if the file does not exist. Once you have the file, you can check an 'Exists' property.
In my case I needed to overwrite the existing file, which meant first deciding if it exists, then deleting it.
(Where web is an SPWeb object)
if (web.GetFile(FilePath).Exists)
web.GetFile(FilePath).Delete();
web.Folders["FolderName"].Files.Add(Filename, data);