FileExists handler

Dec 4, 2010 at 2:19 AM

Hi.  I'm making good use of the control.

Could you please post sample code that would allow me to upload a file that already exists, but append a "-1" onto the filename.  I can do the string manipulations, but I just wanted to see a sample of how to use the FileAlreadyExistsHandler.



Dec 6, 2010 at 2:32 PM

This is the default implementation...

this.FileAlreadyExistsHandler = new Func<string, bool>((fileName) =>
					if (this.AllowFileOverwrite && MessageBox.Show("The requested file [ " + fileName + " ] already exists; overwrite?", "File Exists", MessageBoxButton.OKCancel) == MessageBoxResult.OK)
						return true;
					return false;
Unfortunately it does not afford the opportunity to rename the file, only delete in the CreateNewFile method of your FileHandler (delete if exists).
public override Responses CreateNewFile()
	string file = this.GetFilePath();
		if (File.Exists(file))// If you support overwriting files, do so here.
	catch { }


	return HSS.Interlink.Web.Responses.Success;
I'm working on a file indexing/versioning prototype to support this scenario.