Hello Team,
I am using Rad File Explorer with Telerik file version 2012.2.1002.35 in my application. We are using FileSystemContentProvider to override DeleteFile and DeleteDirectory methods. My issue is when I click Delete button on toolbar or using context menu for deleting file or directory, ItemCommand event of Telerik Rad Fileexplorer is never being hit. Hence Delete is not working for me at all.
Browser: IE 9. We tested this in chrome just to confirm if this is issue with IE alone, but in vain. It does not work in Chrome as well. Below is the code written on OnClientDelete of Rad Explorer.
I am using Rad File Explorer with Telerik file version 2012.2.1002.35 in my application. We are using FileSystemContentProvider to override DeleteFile and DeleteDirectory methods. My issue is when I click Delete button on toolbar or using context menu for deleting file or directory, ItemCommand event of Telerik Rad Fileexplorer is never being hit. Hence Delete is not working for me at all.
Browser: IE 9. We tested this in chrome just to confirm if this is issue with IE alone, but in vain. It does not work in Chrome as well. Below is the code written on OnClientDelete of Rad Explorer.
function
OnClientDelete(sender, args) {
document.getElementById(
"<%=txtfileTag.ClientID%>"
).value =
""
;
LogEvent(
"Delete: "
+ args.get_item().get_name());
setTimeout(
function
() {
sender.refresh();
}, 200);
}
protected
void
RadTrdFile_ItemCommand(
object
sender, RadFileExplorerEventArgs e)
{
objcommon.InsErrorLog(
"Entered Item Command"
, 2,
"EditTeardown.aspx"
,
"RadTrdFile_ItemCommand"
, Convert.ToInt32(Session[
"UserId"
]),
"Chrome or IE"
);
try
{
int
m_countFileexists = 0;
int
m_fileID = 0;
string
m_fileName =
""
;
int
m_count = 0;
int
m_count1 = 0;
string
m_actualPath =
""
;
if
(e.Command ==
"UploadFile"
|| e.Command ==
"DeleteFile"
|| e.Command ==
"MoveFile"
)
{
string
m_fileNamePath = e.Path.ToString();
BllAdministration ObjAdministration =
new
BllAdministration();
// ObjAdministration.MastersId = 7;
//ObjAdministration.UserId = Convert.ToInt32(Session["UserId"]);
ObjTearDown.Type = 7;
DataTable tb = ObjTearDown.LoadMasters();
// DataTable tb = ObjAdministration.LoadMasterFileValues();
foreach
(DataRow dr
in
tb.Rows)
{
if
(e.Path.ToUpper().Contains(dr[
"Description"
].ToString().ToUpper().Trim()))
{
// m_fileID = Convert.ToInt32(dr["MastersValueId"]);
m_fileID = Convert.ToInt32(dr[
"MasterFileValueId"
]);
m_fileName = dr[
"Description"
].ToString().Trim();
break
;
}
}
if
(m_fileID != 0)
{
int
m_index = e.Path.ToUpper().IndexOf(m_fileName.ToUpper());
if
(File.Exists(e.Path))
{
m_countFileexists = 1;
}
string
m_direcoryPath = e.Path.ToUpper().Substring(0, m_index + m_fileName.Length);
m_direcoryPath = m_direcoryPath.Replace(
"/"
,
"\\"
);
DirectoryInfo m_dirInfo =
new
DirectoryInfo(Server.MapPath(m_direcoryPath));
IEnumerable<FileInfo> m_totalFiles = objcommon.GetFilesRecursive(m_dirInfo,
"*.*"
);
m_count = m_totalFiles.Count();
m_count1 = m_totalFiles.Count();
}
}
switch
(e.Command)
{
case
"UploadFile"
:
{
if
(m_countFileexists == 0)
{
string
m_FilePath1 = Server.MapPath(e.Path);
string
dirName1 =
new
DirectoryInfo(m_FilePath1).Name.Replace(
'&'
,
'_'
);
string
fileExtention = Path.GetExtension(m_FilePath1);
if
(fileExtention.ToLower() ==
".jpg"
|| fileExtention.ToLower() ==
".jpeg"
|| fileExtention.ToLower() ==
".gif"
|| fileExtention.ToLower() ==
".png"
|| fileExtention.ToLower() ==
".bmp"
|| fileExtention.ToLower() ==
".tif"
|| fileExtention.ToLower() ==
".tiff"
)
{
m_count = m_count + 2;
}
else
{
m_count = m_count + 1;
}
}
if
(m_fileID != 0)
{
ObjTearDown.MasterFileID = m_fileID;
ObjTearDown.MappedFolderPath = m_actualPath;
ObjTearDown.FileCount = m_count;
ObjTearDown.TearDownId = Request.QueryString[
"TRDID"
];
ObjTearDown.UpdateMasterFileCount();
ObjTearDown.TearDownId = Request.QueryString[
"TRDID"
];
ObjTearDown.MappedFolderPath = m_fileName;
ObjTearDown.FileCount = m_count;
ObjTearDown.InsTRDFiles();
}
if
(m_count1 == 0)
{
DataTable dt = objcommon.GetMailSettings();
if
(dt.Rows.Count > 0)
{
if
(dt.Rows[0][
"IsTRDUploadEnabled"
].ToString() ==
"True"
)
{
SendMailDataUpload(Request.QueryString[
"TRDID"
].ToString(), m_fileName, Request.QueryString[
"TRDID"
].ToString(), hdnwrno.Value);
}
}
}
string
m_FilePath = Server.MapPath(e.Path);
string
dirName =
new
DirectoryInfo(m_FilePath).Name.Replace(
'&'
,
'_'
);
objcommon.InsAuditLog(
"U"
,
"tbl_TRD"
, Request.QueryString[
"TRDID"
].ToString(),
Request.QueryString[
"TRDID"
].ToString(), Request.QueryString[
"TRDID"
].ToString(),
"UploadFile"
,
null
, dirName, Convert.ToInt32(Session[
"UserId"
]));
}
break
;
case
"MoveDirectory"
:
{
Session[
"Id"
] = Request.QueryString[
"TRDID"
].ToString();
Session[
"Type"
] =
"T"
;
string
foldername = hdnFoldername.Value;
string
oldfoldername =
new
DirectoryInfo(hdnoldFoldername.Value).Name;
objcommon.InsAuditLog(
"U"
,
"tbl_TRD"
, Request.QueryString[
"TRDID"
].ToString(),
Request.QueryString[
"TRDID"
].ToString(), Request.QueryString[
"TRDID"
].ToString(),
"MoveDirectory"
, oldfoldername, foldername, Convert.ToInt32(Session[
"UserId"
]));
}
break
;
case
"CreateDirectory"
:
{
string
foldername = hdnFoldername.Value;
objcommon.InsAuditLog(
"U"
,
"tbl_TRD"
, Request.QueryString[
"TRDID"
].ToString(),
Request.QueryString[
"TRDID"
].ToString(), Request.QueryString[
"TRDID"
].ToString(),
"CreateDirectory"
,
""
, foldername, Convert.ToInt32(Session[
"UserId"
]));
}
break
;
case
"DeleteDirectory"
:
{
DirectoryInfo[] m_SubDir;
FileInfo[] m_files;
int
m_SubDirCount = 0;
int
m_DirCount = 0;
string
m_FilePath = Server.MapPath(e.Path);
//~results/MappedFoldertest/" +
DirectoryInfo m_Dir =
new
DirectoryInfo(m_FilePath);
string
dirName =
new
DirectoryInfo(m_FilePath).Name;
if
(m_Dir.GetDirectories().Length > 0)
{
m_SubDir = m_Dir.GetDirectories();
m_SubDirCount = m_SubDir.Length;
}
if
(m_Dir.GetFiles().Length > 0)
{
m_files = m_Dir.GetFiles();
m_DirCount = m_files.Length;
}
objcommon.InsErrorLog(
"Count"
+ m_DirCount.ToString(), 2,
"EditTeardown.aspx"
,
"Delete Directory"
, Convert.ToInt32(Session[
"UserId"
]),
"Chrome or IE"
);
if
(m_DirCount > 0 || m_SubDirCount > 0)
{
//ScriptManager.RegisterClientScriptBlock(Page, Page.GetType(), "alert", "alert('The folder cannot be deleted.Sub Folder(s) or File(s) exist in this folder.')", true);
ScriptManager.RegisterStartupScript(Page, Page.GetType(),
"alert"
,
"alert('The folder cannot be deleted.Sub Folder(s) or File(s) exist in this folder.')"
,
true
);
e.Cancel =
true
;
return
;
}
else
{
string
foldername = hdnFoldername.Value;
objcommon.InsAuditLog(
"D"
,
"tbl_TRD"
, Request.QueryString[
"TRDID"
].ToString(),
Request.QueryString[
"TRDID"
].ToString(), Request.QueryString[
"TRDID"
].ToString(),
"DeleteDirectory"
,
""
, dirName, Convert.ToInt32(Session[
"UserId"
]));
}
}
break
;
case
"DeleteFile"
:
{
if
(m_fileID != 0)
{
// m_count = m_count - 2;
string
m_FilePath1 = Server.MapPath(e.Path);
string
dirName1 =
new
DirectoryInfo(m_FilePath1).Name.Replace(
'&'
,
'_'
);
string
fileExtention = Path.GetExtension(m_FilePath1);
if
(fileExtention.ToLower() ==
".jpg"
|| fileExtention.ToLower() ==
".jpeg"
|| fileExtention.ToLower() ==
".gif"
|| fileExtention.ToLower() ==
".png"
|| fileExtention.ToLower() ==
".bmp"
|| fileExtention.ToLower() ==
".tif"
|| fileExtention.ToLower() ==
".tiff"
)
{
m_count = m_count - 2;
}
else
{
m_count = m_count - 1;
}
ObjTearDown.MasterFileID = m_fileID;
ObjTearDown.MappedFolderPath = m_actualPath;
ObjTearDown.FileCount = m_count;
ObjTearDown.TearDownId = Request.QueryString[
"TRDID"
];
ObjTearDown.UpdateMasterFileCount();
string
path = e.Path;
path = path.Substring(1, path.Length - 1);
int
index = path.IndexOf(
'/'
);
path = path.Substring(index);
ObjTearDown.FilePath = path;
ObjTearDown.TearDownId = Request.QueryString[
"TRDID"
];
ObjTearDown.DelTRDAnalysisFileTag();
ObjTearDown.TearDownId = Request.QueryString[
"TRDID"
];
ObjTearDown.MappedFolderPath = m_fileName;
ObjTearDown.FileCount = m_count;
ObjTearDown.InsTRDFiles();
objcommon.InsErrorLog(
"Count"
+ m_count.ToString(), 2,
"EditTeardown.aspx"
,
"Delete Files"
, Convert.ToInt32(Session[
"UserId"
]),
"Chrome or IE"
);
}
string
m_FilePath = Server.MapPath(e.Path);
string
dirName =
new
DirectoryInfo(m_FilePath).Name;
objcommon.InsAuditLog(
"D"
,
"tbl_TRD"
, Request.QueryString[
"TRDID"
].ToString(),
Request.QueryString[
"TRDID"
].ToString(), Request.QueryString[
"TRDID"
].ToString(),
"DeleteFile"
,
null
, dirName, Convert.ToInt32(Session[
"UserId"
]));
}
break
;
case
"MoveFile"
:
{
Session[
"Id"
] = Request.QueryString[
"TRDID"
].ToString();
Session[
"Type"
] =
"T"
;
string
oldpath = hdnoldFoldername.Value;
string
newpath = hdnFoldername.Value;
string
[] newpatharray = newpath.Split(
'/'
);
string
newFolder = newpatharray.Last();
ObjTearDown.FilePath = m_fileName;
ObjTearDown.TearDownId = Request.QueryString[
"TRDID"
];
ObjTearDown.DelTRDAnalysisFileTag();
ObjTearDown.TearDownId = Request.QueryString[
"TRDID"
].ToString() +
","
+ m_fileName;
ObjTearDown.MappedFolderPath = newFolder;
ObjTearDown.FileCount = m_count;
ObjTearDown.InsTRDFiles();
}
break
;
case
"CopyFile"
:
{
Session[
"Id"
] = Request.QueryString[
"TRDID"
].ToString();
Session[
"Type"
] =
"T"
;
}
break
;
}
// e.Cancel = true; // Cancel the operation
}
catch
(Exception ce)
{
string
BrowserType = Request.Browser.Browser +
" "
+ Request.Browser.Version +
" "
+ Request.Browser.Platform;
objcommon.InsError(ce.Message.ToString() +
"<br/> Method Name : RadTrdFile_ItemCommand <br/> Page Name :EditTeardown.aspx"
);
objcommon.InsErrorLog(ce.Message.ToString(), 2,
"EditTeardown.aspx"
,
"RadTrdFile_ItemCommand"
, Convert.ToInt32(Session[
"UserId"
]), BrowserType);
}
}
public
override
string
DeleteFile(
string
path)
{
BllCommon objcommon =
new
BllCommon();
objcommon.InsErrorLog(
"In Delete File overriden "
, 2,
"EditTeardown.aspx"
,
"Delete File"
, 1,
"Chrome or IE"
);
string
physicalPath = MapPath(RemoveProtocolNameAndServerName(path));
try
{
if
(File.Exists(physicalPath))
{
File.Delete(physicalPath);
try
{
File.Delete(physicalPath.Replace(
".thumb"
,
""
));
}
catch
{
File.Delete(physicalPath.Replace(
".thumb"
,
""
));
}
}
}
catch
(UnauthorizedAccessException)
{
return
"NoPermissionsToDeleteFile"
;
}
return
string
.Empty;
}
public
override
string
DeleteDirectory(
string
path)
{
BllCommon objcommon =
new
BllCommon();
objcommon.InsErrorLog(
"In Delete Directory overriden "
, 2,
"EditTeardown.aspx"
,
"Delete Directory"
, 1,
"Chrome or IE"
);
string
absolutePath = MapPath(RemoveProtocolNameAndServerName(path));
try
{
if
(Directory.Exists(absolutePath))
{
if
(Directory.GetFiles(absolutePath).Length == 0)
Directory.Delete(absolutePath);
}
}
catch
(UnauthorizedAccessException)
{
return
"NoPermissionsToDeleteFile"
;
}
return
string
.Empty;
}