I'm trying to add a alert inside the FileStore method in Telerik's File Explorer, but it's not working as expected. Here's my implementation:
public override string StoreFile(UploadedFile file, string path, string name, params string[] arguments)
{
string physicalPath = this.GetPhysicalFromVirtualPath(path);
if (physicalPath == null)
return string.Empty;
Directory.CreateDirectory(physicalPath);
// sanitize the file name
name = (name.Replace(" ", "_")).Replace("'", string.Empty);
physicalPath = PathHelper.AddEndingSlash(physicalPath, '\\') + name;
string fileName = Path.GetFileName(physicalPath);
string folderPath = Path.GetDirectoryName(physicalPath);
FileStorageManager fileStorageManager = new FileStorageManager();
FileStorageInformation fileInfo = fileStorageManager.GetFileByFolderAndFileName(_applicationID, folderPath, fileName);
string fileFolderRelativeToRoot = path;
string rootToThisContext = path;
string message = null;
if (File.Exists(physicalPath))
{
bool isVersioningDisabledOnDestination = false;
UploadingHandler uploadingHandler = new UploadingHandler();
uploadingHandler.ExecuteAction(fileInfo, fileName, fileFolderRelativeToRoot, rootToThisContext, _applicationID, _formID, _userID, ref isVersioningDisabledOnDestination);
if (isVersioningDisabledOnDestination)
{
message = string.Format("Can not upload - versioning not enabled on target folder");
}
}
if(message == null)
{
file.SaveAs(physicalPath);
return PathHelper.AddEndingSlash(path, '/') + name;
}
else
{
return message;
}
}
public override string StoreFile(UploadedFile file, string path, string name, params string[] arguments)
{
string physicalPath = this.GetPhysicalFromVirtualPath(path);
if (physicalPath == null)
return string.Empty;
Directory.CreateDirectory(physicalPath);
// sanitize the file name
name = (name.Replace(" ", "_")).Replace("'", string.Empty);
physicalPath = PathHelper.AddEndingSlash(physicalPath, '\\') + name;
string fileName = Path.GetFileName(physicalPath);
string folderPath = Path.GetDirectoryName(physicalPath);
FileStorageManager fileStorageManager = new FileStorageManager();
FileStorageInformation fileInfo = fileStorageManager.GetFileByFolderAndFileName(_applicationID, folderPath, fileName);
string fileFolderRelativeToRoot = path;
string rootToThisContext = path;
string message = null;
if (File.Exists(physicalPath))
{
bool isVersioningDisabledOnDestination = false;
UploadingHandler uploadingHandler = new UploadingHandler();
uploadingHandler.ExecuteAction(fileInfo, fileName, fileFolderRelativeToRoot, rootToThisContext, _applicationID, _formID, _userID, ref isVersioningDisabledOnDestination);
if (isVersioningDisabledOnDestination)
{
message = string.Format("Can not upload - versioning not enabled on target folder");
}
}
if(message == null)
{
file.SaveAs(physicalPath);
return PathHelper.AddEndingSlash(path, '/') + name;
}
else
{
return message;
}
}